@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
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"documentSymbolProvider.js","sourceRoot":"","sources":["../../../src/languageService/documentSymbolProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;AAEH,iEAO+B;AAC/B,2CAAiC;AAGjC,+EAAiE;AAEjE,mEAA+F;AAC/F,yDAA6F;AAE7F,qDAAkE;AAClE,mEAA2E;AAC3E,2DAAgE;AAChE,mEAAqD;AAGrD,iDAAuE;AAgCvE,SAAgB,iBAAiB,CAC7B,YAA0B,EAC1B,WAA6B;;IAE7B,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;QACzB,OAAO,SAAS,CAAC;KACpB;IAED,MAAM,YAAY,GAAG,IAAA,0CAAuB,
|
1
|
+
{"version":3,"file":"documentSymbolProvider.js","sourceRoot":"","sources":["../../../src/languageService/documentSymbolProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;AAEH,iEAO+B;AAC/B,2CAAiC;AAGjC,+EAAiE;AAEjE,mEAA+F;AAC/F,yDAA6F;AAE7F,qDAAkE;AAClE,mEAA2E;AAC3E,2DAAgE;AAChE,mEAAqD;AAGrD,iDAAuE;AAgCvE,SAAgB,iBAAiB,CAC7B,YAA0B,EAC1B,WAA6B;;IAE7B,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;QACzB,OAAO,SAAS,CAAC;KACpB;IAED,MAAM,YAAY,GAAG,IAAA,0CAAuB,EAAC,YAAY,EAAE,WAAW,EAAE;QACpE,iBAAiB,EAAE,IAAI;QACvB,2BAA2B,EAAE,KAAK;QAClC,mBAAmB,EAAE,KAAK;KAC7B,CAAC,CAAC;IACH,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC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EAAE,MAAM,CAAC,KAAK,CAAC;KACvD,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,EAAE;QACb,UAAU,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;KACjC;IAED,IAAI,MAAM,EAAE;QACR,UAAU,CAAC,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC;KAC1C;IAED,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE7B,IAAI,MAAM,CAAC,QAAQ,EAAE;QACjB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE;YACjC,4BAA4B,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;SACzE;KACJ;AACL,CAAC"}
|
@@ -1,31 +1,31 @@
|
|
1
1
|
import { CancellationToken, Hover, MarkupKind } from 'vscode-languageserver';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { SignatureDisplayType } from '../common/configOptions';
|
5
|
-
import { Position, Range } from '../common/textRange';
|
6
|
-
import { ParseResults } from '../parser/parser';
|
7
|
-
export interface HoverTextPart {
|
8
|
-
python?: boolean;
|
9
|
-
text: string;
|
10
|
-
}
|
11
|
-
export interface HoverResults {
|
12
|
-
parts: HoverTextPart[];
|
13
|
-
lastKnownModule?: string;
|
14
|
-
range: Range;
|
15
|
-
}
|
2
|
+
import { ProgramView } from '../common/extensibility';
|
3
|
+
import { Position } from '../common/textRange';
|
16
4
|
export declare class HoverProvider {
|
17
|
-
|
18
|
-
private
|
19
|
-
private
|
20
|
-
private
|
21
|
-
private
|
22
|
-
private
|
23
|
-
private
|
24
|
-
private
|
25
|
-
|
26
|
-
|
27
|
-
private
|
28
|
-
private
|
29
|
-
private
|
5
|
+
private _program;
|
6
|
+
private _filePath;
|
7
|
+
private _position;
|
8
|
+
private _format;
|
9
|
+
private _supportTelemetry;
|
10
|
+
private _token;
|
11
|
+
private readonly _parseResults;
|
12
|
+
private readonly _sourceMapper;
|
13
|
+
constructor(_program: ProgramView, _filePath: string, _position: Position, _format: MarkupKind, _supportTelemetry: boolean, _token: CancellationToken);
|
14
|
+
getHover(): Hover | undefined;
|
15
|
+
private get _evaluator();
|
16
|
+
private get _functionSignatureDisplay();
|
17
|
+
private _getHoverResult;
|
18
|
+
private _addResultsForDeclaration;
|
19
|
+
private _tryAddPartsForTypedDictKey;
|
20
|
+
private _addInitOrNewMethodInsteadIfCallNode;
|
21
|
+
private _getTypeText;
|
22
|
+
private _getTypesText;
|
23
|
+
private _bindFunctionToClassOrObject;
|
24
|
+
private _getType;
|
25
|
+
private _limitOverloadBasedOnCall;
|
26
|
+
private _addDocumentationPart;
|
27
|
+
private _addDocumentationPartForType;
|
28
|
+
private _addDocumentationResultsPart;
|
29
|
+
private _addResultsPart;
|
30
|
+
private _convertHoverResults;
|
30
31
|
}
|
31
|
-
export declare function convertHoverResults(format: MarkupKind, hoverResults: HoverResults | undefined, includeHash?: boolean): Hover | undefined;
|
@@ -29,12 +29,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
29
29
|
return result;
|
30
30
|
};
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
32
|
-
exports.
|
32
|
+
exports.HoverProvider = void 0;
|
33
33
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
34
34
|
const docStringConversion_1 = require("../analyzer/docStringConversion");
|
35
35
|
const ParseTreeUtils = __importStar(require("../analyzer/parseTreeUtils"));
|
36
|
-
const types_1 = require("../analyzer/types");
|
37
36
|
const typeUtils_1 = require("../analyzer/typeUtils");
|
37
|
+
const types_1 = require("../analyzer/types");
|
38
38
|
const cancellationUtils_1 = require("../common/cancellationUtils");
|
39
39
|
const debug_1 = require("../common/debug");
|
40
40
|
const extensibility_1 = require("../common/extensibility");
|
@@ -44,22 +44,44 @@ const textRange_1 = require("../common/textRange");
|
|
44
44
|
const parseNodes_1 = require("../parser/parseNodes");
|
45
45
|
const tooltipUtils_1 = require("./tooltipUtils");
|
46
46
|
class HoverProvider {
|
47
|
-
|
47
|
+
constructor(_program, _filePath, _position, _format, _supportTelemetry, _token) {
|
48
|
+
this._program = _program;
|
49
|
+
this._filePath = _filePath;
|
50
|
+
this._position = _position;
|
51
|
+
this._format = _format;
|
52
|
+
this._supportTelemetry = _supportTelemetry;
|
53
|
+
this._token = _token;
|
54
|
+
this._parseResults = this._program.getParseResults(this._filePath);
|
55
|
+
this._sourceMapper = this._program.getSourceMapper(this._filePath, this._token, /* mapCompiled */ true);
|
56
|
+
}
|
57
|
+
getHover() {
|
58
|
+
return this._convertHoverResults(this._getHoverResult());
|
59
|
+
}
|
60
|
+
get _evaluator() {
|
61
|
+
return this._program.evaluator;
|
62
|
+
}
|
63
|
+
get _functionSignatureDisplay() {
|
64
|
+
return this._program.configOptions.functionSignatureDisplay;
|
65
|
+
}
|
66
|
+
_getHoverResult() {
|
48
67
|
var _a;
|
49
|
-
(0, cancellationUtils_1.throwIfCancellationRequested)(
|
50
|
-
|
68
|
+
(0, cancellationUtils_1.throwIfCancellationRequested)(this._token);
|
69
|
+
if (!this._parseResults) {
|
70
|
+
return undefined;
|
71
|
+
}
|
72
|
+
const offset = (0, positionUtils_1.convertPositionToOffset)(this._position, this._parseResults.tokenizerOutput.lines);
|
51
73
|
if (offset === undefined) {
|
52
74
|
return undefined;
|
53
75
|
}
|
54
|
-
const node = ParseTreeUtils.findNodeByOffset(
|
76
|
+
const node = ParseTreeUtils.findNodeByOffset(this._parseResults.parseTree, offset);
|
55
77
|
if (node === undefined) {
|
56
78
|
return undefined;
|
57
79
|
}
|
58
80
|
const results = {
|
59
81
|
parts: [],
|
60
82
|
range: {
|
61
|
-
start: (0, positionUtils_1.convertOffsetToPosition)(node.start,
|
62
|
-
end: (0, positionUtils_1.convertOffsetToPosition)(textRange_1.TextRange.getEnd(node),
|
83
|
+
start: (0, positionUtils_1.convertOffsetToPosition)(node.start, this._parseResults.tokenizerOutput.lines),
|
84
|
+
end: (0, positionUtils_1.convertOffsetToPosition)(textRange_1.TextRange.getEnd(node), this._parseResults.tokenizerOutput.lines),
|
63
85
|
},
|
64
86
|
};
|
65
87
|
if (node.nodeType === 38 /* Name */) {
|
@@ -67,11 +89,11 @@ class HoverProvider {
|
|
67
89
|
let declarations = extensibility_1.Extensions.getProgramExtensions(node)
|
68
90
|
.map((e) => {
|
69
91
|
var _a;
|
70
|
-
return ((_a = e.declarationProviderExtension) === null || _a === void 0 ? void 0 : _a.tryGetDeclarations(
|
92
|
+
return ((_a = e.declarationProviderExtension) === null || _a === void 0 ? void 0 : _a.tryGetDeclarations(this._evaluator, node, offset, extensibility_1.DeclarationUseCase.Definition, this._token)) || [];
|
71
93
|
})
|
72
94
|
.flat();
|
73
95
|
if (declarations.length === 0) {
|
74
|
-
declarations =
|
96
|
+
declarations = this._evaluator.getDeclarationsForNameNode(node);
|
75
97
|
}
|
76
98
|
if (declarations && declarations.length > 0) {
|
77
99
|
// In most cases, it's best to treat the first declaration as the
|
@@ -92,7 +114,7 @@ class HoverProvider {
|
|
92
114
|
// Slots cannot have docstrings, so pick the secondary.
|
93
115
|
primaryDeclaration = declarations[1];
|
94
116
|
}
|
95
|
-
this._addResultsForDeclaration(
|
117
|
+
this._addResultsForDeclaration(results.parts, primaryDeclaration, node);
|
96
118
|
// Add the lastKnownModule for this declaration. We'll use this
|
97
119
|
// in telemetry for hover.
|
98
120
|
results.lastKnownModule = primaryDeclaration.moduleName;
|
@@ -103,7 +125,7 @@ class HoverProvider {
|
|
103
125
|
// is a directory (a namespace package), and we don't want to provide any hover
|
104
126
|
// information in that case.
|
105
127
|
if (results.parts.length === 0) {
|
106
|
-
const type = this._getType(
|
128
|
+
const type = this._getType(node);
|
107
129
|
let typeText;
|
108
130
|
if ((0, types_1.isModule)(type)) {
|
109
131
|
// Handle modules specially because submodules aren't associated with
|
@@ -118,38 +140,36 @@ class HoverProvider {
|
|
118
140
|
isProperty = true;
|
119
141
|
label = 'property';
|
120
142
|
}
|
121
|
-
typeText = (0, tooltipUtils_1.getToolTipForType)(type, label, node.value,
|
143
|
+
typeText = (0, tooltipUtils_1.getToolTipForType)(type, label, node.value, this._evaluator, isProperty, this._functionSignatureDisplay);
|
122
144
|
}
|
123
145
|
this._addResultsPart(results.parts, typeText, /* python */ true);
|
124
|
-
this._addDocumentationPart(
|
125
|
-
/* resolvedDecl */ undefined);
|
146
|
+
this._addDocumentationPart(results.parts, node, /* resolvedDecl */ undefined);
|
126
147
|
}
|
127
148
|
}
|
128
149
|
}
|
129
150
|
else if (node.nodeType === 49 /* String */) {
|
130
|
-
const type = (_a =
|
151
|
+
const type = (_a = this._evaluator.getExpectedType(node)) === null || _a === void 0 ? void 0 : _a.type;
|
131
152
|
if (type !== undefined) {
|
132
|
-
this._tryAddPartsForTypedDictKey(
|
153
|
+
this._tryAddPartsForTypedDictKey(node, type, results.parts);
|
133
154
|
}
|
134
155
|
}
|
135
156
|
return results.parts.length > 0 ? results : undefined;
|
136
157
|
}
|
137
|
-
|
158
|
+
_addResultsForDeclaration(parts, declaration, node) {
|
138
159
|
var _a, _b;
|
139
|
-
const resolvedDecl =
|
160
|
+
const resolvedDecl = this._evaluator.resolveAliasDeclaration(declaration, /* resolveLocalNames */ true);
|
140
161
|
if (!resolvedDecl) {
|
141
|
-
this._addResultsPart(parts, `(import) ` + node.value + this._getTypeText(node,
|
142
|
-
/* python */ true);
|
162
|
+
this._addResultsPart(parts, `(import) ` + node.value + this._getTypeText(node), /* python */ true);
|
143
163
|
return;
|
144
164
|
}
|
145
165
|
switch (resolvedDecl.type) {
|
146
166
|
case 0 /* Intrinsic */: {
|
147
|
-
this._addResultsPart(parts, node.value + this._getTypeText(node
|
148
|
-
this._addDocumentationPart(
|
167
|
+
this._addResultsPart(parts, node.value + this._getTypeText(node), /* python */ true);
|
168
|
+
this._addDocumentationPart(parts, node, resolvedDecl);
|
149
169
|
break;
|
150
170
|
}
|
151
171
|
case 1 /* Variable */: {
|
152
|
-
let label = resolvedDecl.isConstant ||
|
172
|
+
let label = resolvedDecl.isConstant || this._evaluator.isFinalVariableDeclaration(resolvedDecl)
|
153
173
|
? 'constant'
|
154
174
|
: 'variable';
|
155
175
|
// If the named node is an aliased import symbol, we can't call
|
@@ -174,12 +194,12 @@ class HoverProvider {
|
|
174
194
|
}
|
175
195
|
// Determine if this identifier is a type alias. If so, expand
|
176
196
|
// the type alias when printing the type information.
|
177
|
-
let type = this._getType(
|
197
|
+
let type = this._getType(typeNode);
|
178
198
|
// We may have more type information in the alternativeTypeNode. Use that if it's better.
|
179
199
|
if ((0, types_1.isUnknown)(type) &&
|
180
200
|
resolvedDecl.alternativeTypeNode &&
|
181
201
|
(0, parseNodes_1.isExpressionNode)(resolvedDecl.alternativeTypeNode)) {
|
182
|
-
const inferredType = this._getType(
|
202
|
+
const inferredType = this._getType(resolvedDecl.alternativeTypeNode);
|
183
203
|
if (!(0, types_1.isUnknown)(inferredType)) {
|
184
204
|
type = inferredType;
|
185
205
|
typeNode = resolvedDecl.alternativeTypeNode;
|
@@ -201,89 +221,90 @@ class HoverProvider {
|
|
201
221
|
}
|
202
222
|
}
|
203
223
|
let typeText;
|
204
|
-
const varType = this._getType(
|
224
|
+
const varType = this._getType(typeNode);
|
205
225
|
// Handle the case where type is a function and was assigned to a variable.
|
206
226
|
if (varType.category === 5 /* Function */ ||
|
207
227
|
varType.category === 6 /* OverloadedFunction */) {
|
208
|
-
typeText = (0, tooltipUtils_1.getToolTipForType)(type, label, node.value,
|
209
|
-
/* isProperty */ false,
|
228
|
+
typeText = (0, tooltipUtils_1.getToolTipForType)(type, label, node.value, this._evaluator,
|
229
|
+
/* isProperty */ false, this._functionSignatureDisplay);
|
210
230
|
}
|
211
231
|
else {
|
212
|
-
typeText = typeVarName || node.value + this._getTypeText(typeNode,
|
232
|
+
typeText = typeVarName || node.value + this._getTypeText(typeNode, expandTypeAlias);
|
213
233
|
typeText = `(${label}) ` + typeText;
|
214
234
|
}
|
215
235
|
this._addResultsPart(parts, typeText, /* python */ true);
|
216
|
-
this._addDocumentationPart(
|
236
|
+
this._addDocumentationPart(parts, node, resolvedDecl);
|
217
237
|
break;
|
218
238
|
}
|
219
239
|
case 2 /* Parameter */: {
|
220
240
|
if (resolvedDecl.inferredName && resolvedDecl.inferredTypeNodes) {
|
221
|
-
this._addResultsPart(parts, '(parameter) ' +
|
222
|
-
resolvedDecl.inferredName +
|
223
|
-
this._getTypesText(resolvedDecl.inferredTypeNodes, evaluator),
|
241
|
+
this._addResultsPart(parts, '(parameter) ' + resolvedDecl.inferredName + this._getTypesText(resolvedDecl.inferredTypeNodes),
|
224
242
|
/* python */ true);
|
225
243
|
}
|
226
244
|
else {
|
227
|
-
this._addResultsPart(parts, '(parameter) ' + node.value + this._getTypeText(node
|
245
|
+
this._addResultsPart(parts, '(parameter) ' + node.value + this._getTypeText(node),
|
228
246
|
/* python */ true);
|
229
247
|
}
|
230
248
|
if (resolvedDecl.docString) {
|
231
249
|
this._addResultsPart(parts, resolvedDecl.docString);
|
232
250
|
}
|
233
|
-
this._addDocumentationPart(
|
251
|
+
this._addDocumentationPart(parts, node, resolvedDecl);
|
234
252
|
break;
|
235
253
|
}
|
236
254
|
case 3 /* TypeParameter */: {
|
237
|
-
this._addResultsPart(parts, '(type parameter) ' + node.value + this._getTypeText(node
|
255
|
+
this._addResultsPart(parts, '(type parameter) ' + node.value + this._getTypeText(node),
|
238
256
|
/* python */ true);
|
239
|
-
this._addDocumentationPart(
|
257
|
+
this._addDocumentationPart(parts, node, resolvedDecl);
|
240
258
|
break;
|
241
259
|
}
|
242
260
|
case 6 /* Class */:
|
243
261
|
case 7 /* SpecialBuiltInClass */: {
|
244
262
|
const nameNode = resolvedDecl.type === 6 /* Class */ ? resolvedDecl.node.name : node;
|
245
|
-
if (this._addInitOrNewMethodInsteadIfCallNode(
|
263
|
+
if (this._addInitOrNewMethodInsteadIfCallNode(node, parts, resolvedDecl)) {
|
246
264
|
return;
|
247
265
|
}
|
248
266
|
this._addResultsPart(parts, '(class) ' + nameNode.value, /* python */ true);
|
249
|
-
this._addDocumentationPart(
|
267
|
+
this._addDocumentationPart(parts, node, resolvedDecl);
|
250
268
|
break;
|
251
269
|
}
|
252
270
|
case 5 /* Function */: {
|
253
271
|
let label = 'function';
|
254
272
|
let isProperty = false;
|
255
273
|
if (resolvedDecl.isMethod) {
|
256
|
-
const declaredType = (_b =
|
274
|
+
const declaredType = (_b = this._evaluator.getTypeForDeclaration(resolvedDecl)) === null || _b === void 0 ? void 0 : _b.type;
|
257
275
|
isProperty = !!declaredType && (0, typeUtils_1.isMaybeDescriptorInstance)(declaredType, /* requireSetter */ false);
|
258
276
|
label = isProperty ? 'property' : 'method';
|
259
277
|
}
|
260
|
-
let type = this._getType(
|
278
|
+
let type = this._getType(node);
|
261
279
|
const resolvedType = extensibility_1.Extensions.getProgramExtensions(resolvedDecl.node)
|
262
|
-
.map((e) => {
|
263
|
-
|
280
|
+
.map((e) => {
|
281
|
+
var _a;
|
282
|
+
return (_a = e.typeProviderExtension) === null || _a === void 0 ? void 0 : _a.tryGetFunctionNodeType(resolvedDecl.node, this._evaluator, this._token);
|
283
|
+
})
|
284
|
+
.find((t) => !!t) || this._getType(resolvedDecl.node.name);
|
264
285
|
type = (0, types_1.isAnyOrUnknown)(type) ? resolvedType : type;
|
265
|
-
const signatureString = (0, tooltipUtils_1.getToolTipForType)(type, label, node.value,
|
286
|
+
const signatureString = (0, tooltipUtils_1.getToolTipForType)(type, label, node.value, this._evaluator, isProperty, this._functionSignatureDisplay);
|
266
287
|
this._addResultsPart(parts, signatureString, /* python */ true);
|
267
|
-
this._addDocumentationPart(
|
288
|
+
this._addDocumentationPart(parts, node, resolvedDecl);
|
268
289
|
break;
|
269
290
|
}
|
270
291
|
case 8 /* Alias */: {
|
271
292
|
// First the 'module' header.
|
272
293
|
this._addResultsPart(parts, '(module) ' + node.value, /* python */ true);
|
273
|
-
this._addDocumentationPart(
|
294
|
+
this._addDocumentationPart(parts, node, resolvedDecl);
|
274
295
|
break;
|
275
296
|
}
|
276
297
|
case 4 /* TypeAlias */: {
|
277
|
-
const typeText = node.value + this._getTypeText(node,
|
298
|
+
const typeText = node.value + this._getTypeText(node, /* expandTypeAlias */ true);
|
278
299
|
this._addResultsPart(parts, `(type alias) ${typeText}`, /* python */ true);
|
279
|
-
this._addDocumentationPart(
|
300
|
+
this._addDocumentationPart(parts, node, resolvedDecl);
|
280
301
|
break;
|
281
302
|
}
|
282
303
|
default:
|
283
304
|
(0, debug_1.assertNever)(resolvedDecl);
|
284
305
|
}
|
285
306
|
}
|
286
|
-
|
307
|
+
_tryAddPartsForTypedDictKey(node, type, parts) {
|
287
308
|
// If the expected type is a TypedDict and the current node is a key entry then we can provide a tooltip
|
288
309
|
// with the type of the TypedDict key and its docstring, if available.
|
289
310
|
(0, typeUtils_1.doForEachSubtype)(type, (subtype) => {
|
@@ -297,7 +318,7 @@ class HoverProvider {
|
|
297
318
|
parts.push({ text: '\n\n---\n' });
|
298
319
|
}
|
299
320
|
// e.g. (key) name: str
|
300
|
-
const text = '(key) ' + node.value + ': ' +
|
321
|
+
const text = '(key) ' + node.value + ': ' + this._evaluator.printType(entry.valueType);
|
301
322
|
this._addResultsPart(parts, text, /* python */ true);
|
302
323
|
const declarations = (_b = subtype.details.fields.get(node.value)) === null || _b === void 0 ? void 0 : _b.getDeclarations();
|
303
324
|
if (declarations !== undefined && (declarations === null || declarations === void 0 ? void 0 : declarations.length) !== 0) {
|
@@ -306,14 +327,14 @@ class HoverProvider {
|
|
306
327
|
// than one declaration for a TypedDict key variable.
|
307
328
|
const declaration = declarations[0];
|
308
329
|
if (declaration.type === 1 /* Variable */ && declaration.docString !== undefined) {
|
309
|
-
this._addDocumentationPartForType(
|
330
|
+
this._addDocumentationPartForType(parts, subtype, declaration);
|
310
331
|
}
|
311
332
|
}
|
312
333
|
}
|
313
334
|
}
|
314
335
|
});
|
315
336
|
}
|
316
|
-
|
337
|
+
_addInitOrNewMethodInsteadIfCallNode(node, parts, declaration) {
|
317
338
|
var _a, _b;
|
318
339
|
// If the class is used as part of a call (i.e. it is being
|
319
340
|
// instantiated), include the constructor arguments within the
|
@@ -335,11 +356,11 @@ class HoverProvider {
|
|
335
356
|
return false;
|
336
357
|
}
|
337
358
|
// Get the init method for this class.
|
338
|
-
const classType = this._getType(
|
359
|
+
const classType = this._getType(node);
|
339
360
|
if (!(0, types_1.isInstantiableClass)(classType)) {
|
340
361
|
return false;
|
341
362
|
}
|
342
|
-
const instanceType = this._getType(
|
363
|
+
const instanceType = this._getType(callLeftNode.parent);
|
343
364
|
if (!(0, types_1.isClassInstance)(instanceType)) {
|
344
365
|
return false;
|
345
366
|
}
|
@@ -348,9 +369,9 @@ class HoverProvider {
|
|
348
369
|
// Don't exclude `object.__init__` since in the plain case we want to show Foo().
|
349
370
|
const initMember = (0, typeUtils_1.lookUpClassMember)(classType, '__init__', 8 /* SkipInstanceVariables */);
|
350
371
|
if (initMember) {
|
351
|
-
const functionType =
|
372
|
+
const functionType = this._evaluator.getTypeOfMember(initMember);
|
352
373
|
if ((0, types_1.isFunction)(functionType) || (0, types_1.isOverloadedFunction)(functionType)) {
|
353
|
-
methodType = this._bindFunctionToClassOrObject(
|
374
|
+
methodType = this._bindFunctionToClassOrObject(node, instanceType, functionType);
|
354
375
|
}
|
355
376
|
}
|
356
377
|
// If there was no `__init__`, excluding `object` class `__init__`, or if `__init__` only had default params (*args: Any, **kwargs: Any) or no params (),
|
@@ -361,52 +382,52 @@ class HoverProvider {
|
|
361
382
|
(types_1.FunctionType.hasDefaultParameters(methodType) || methodType.details.parameters.length === 0))) {
|
362
383
|
const newMember = (0, typeUtils_1.lookUpClassMember)(classType, '__new__', 4 /* SkipObjectBaseClass */ | 8 /* SkipInstanceVariables */);
|
363
384
|
if (newMember) {
|
364
|
-
const newMemberType =
|
385
|
+
const newMemberType = this._evaluator.getTypeOfMember(newMember);
|
365
386
|
// Prefer `__new__` if it doesn't have default params (*args: Any, **kwargs: Any) or no params ().
|
366
387
|
if ((0, types_1.isFunction)(newMemberType) || (0, types_1.isOverloadedFunction)(newMemberType)) {
|
367
388
|
// Set `treatConstructorAsClassMember` to true to exclude `cls` as a parameter.
|
368
|
-
methodType = this._bindFunctionToClassOrObject(
|
389
|
+
methodType = this._bindFunctionToClassOrObject(node, instanceType, newMemberType,
|
369
390
|
/* treatConstructorAsClassMember */ true);
|
370
391
|
}
|
371
392
|
}
|
372
393
|
}
|
373
394
|
if (methodType && ((0, types_1.isFunction)(methodType) || (0, types_1.isOverloadedFunction)(methodType))) {
|
374
|
-
this._addResultsPart(parts, (0, tooltipUtils_1.getConstructorTooltip)(node.value, methodType,
|
395
|
+
this._addResultsPart(parts, (0, tooltipUtils_1.getConstructorTooltip)(node.value, methodType, this._evaluator, this._functionSignatureDisplay),
|
375
396
|
/* python */ true);
|
376
|
-
const addedDoc = this._addDocumentationPartForType(
|
397
|
+
const addedDoc = this._addDocumentationPartForType(parts, methodType, declaration);
|
377
398
|
if (!addedDoc) {
|
378
|
-
this._addDocumentationPartForType(
|
399
|
+
this._addDocumentationPartForType(parts, classType, declaration);
|
379
400
|
}
|
380
401
|
return true;
|
381
402
|
}
|
382
403
|
return false;
|
383
404
|
}
|
384
|
-
|
385
|
-
const type = this._getType(
|
386
|
-
return ': ' +
|
405
|
+
_getTypeText(node, expandTypeAlias = false) {
|
406
|
+
const type = this._getType(node);
|
407
|
+
return ': ' + this._evaluator.printType(type, { expandTypeAlias });
|
387
408
|
}
|
388
|
-
|
389
|
-
const type = (0, tooltipUtils_1.combineExpressionTypes)(nodes,
|
390
|
-
return ': ' +
|
409
|
+
_getTypesText(nodes, expandTypeAlias = false) {
|
410
|
+
const type = (0, tooltipUtils_1.combineExpressionTypes)(nodes, this._evaluator);
|
411
|
+
return ': ' + this._evaluator.printType(type, { expandTypeAlias });
|
391
412
|
}
|
392
|
-
|
393
|
-
const methodType =
|
413
|
+
_bindFunctionToClassOrObject(node, baseType, memberType, treatConstructorAsClassMember) {
|
414
|
+
const methodType = this._evaluator.bindFunctionToClassOrObject(baseType, memberType,
|
394
415
|
/* memberClass */ undefined,
|
395
416
|
/* errorNode */ undefined,
|
396
417
|
/* recursiveCount */ undefined, treatConstructorAsClassMember);
|
397
418
|
if (!methodType) {
|
398
419
|
return undefined;
|
399
420
|
}
|
400
|
-
return this._limitOverloadBasedOnCall(
|
421
|
+
return this._limitOverloadBasedOnCall(methodType, node);
|
401
422
|
}
|
402
|
-
|
423
|
+
_getType(node) {
|
403
424
|
var _a;
|
404
425
|
// It does common work necessary for hover for a type we got
|
405
426
|
// from raw type evaluator.
|
406
|
-
const type = (_a =
|
407
|
-
return this._limitOverloadBasedOnCall(
|
427
|
+
const type = (_a = this._evaluator.getType(node)) !== null && _a !== void 0 ? _a : types_1.UnknownType.create();
|
428
|
+
return this._limitOverloadBasedOnCall(type, node);
|
408
429
|
}
|
409
|
-
|
430
|
+
_limitOverloadBasedOnCall(type, node) {
|
410
431
|
// If it's an overloaded function, see if it's part of a call expression.
|
411
432
|
// If so, we may be able to eliminate some of the overloads based on
|
412
433
|
// the overload resolution.
|
@@ -417,7 +438,7 @@ class HoverProvider {
|
|
417
438
|
if (!callNode) {
|
418
439
|
return type;
|
419
440
|
}
|
420
|
-
const callTypeResult =
|
441
|
+
const callTypeResult = this._evaluator.getTypeResult(callNode);
|
421
442
|
if (!callTypeResult ||
|
422
443
|
!callTypeResult.overloadsUsedForCall ||
|
423
444
|
callTypeResult.overloadsUsedForCall.length === 0) {
|
@@ -428,76 +449,77 @@ class HoverProvider {
|
|
428
449
|
}
|
429
450
|
return types_1.OverloadedFunctionType.create(callTypeResult.overloadsUsedForCall);
|
430
451
|
}
|
431
|
-
|
432
|
-
const type = this._getType(
|
433
|
-
this._addDocumentationPartForType(
|
452
|
+
_addDocumentationPart(parts, node, resolvedDecl) {
|
453
|
+
const type = this._getType(node);
|
454
|
+
this._addDocumentationPartForType(parts, type, resolvedDecl, node.value);
|
434
455
|
}
|
435
|
-
|
436
|
-
const docString = (0, tooltipUtils_1.getDocumentationPartsForTypeAndDecl)(
|
456
|
+
_addDocumentationPartForType(parts, type, resolvedDecl, name) {
|
457
|
+
const docString = (0, tooltipUtils_1.getDocumentationPartsForTypeAndDecl)(this._sourceMapper, type, resolvedDecl, this._evaluator, {
|
458
|
+
name,
|
459
|
+
});
|
437
460
|
if (docString) {
|
438
|
-
this._addDocumentationResultsPart(
|
461
|
+
this._addDocumentationResultsPart(parts, docString);
|
439
462
|
return true;
|
440
463
|
}
|
441
464
|
return false;
|
442
465
|
}
|
443
|
-
|
466
|
+
_addDocumentationResultsPart(parts, docString) {
|
444
467
|
if (docString) {
|
445
|
-
if (
|
468
|
+
if (this._format === vscode_languageserver_1.MarkupKind.Markdown) {
|
446
469
|
const markDown = (0, docStringConversion_1.convertDocStringToMarkdown)(docString);
|
447
470
|
if (parts.length > 0 && markDown.length > 0) {
|
448
471
|
parts.push({ text: '---\n' });
|
449
472
|
}
|
450
473
|
this._addResultsPart(parts, markDown);
|
451
474
|
}
|
452
|
-
else if (
|
475
|
+
else if (this._format === vscode_languageserver_1.MarkupKind.PlainText) {
|
453
476
|
this._addResultsPart(parts, (0, docStringConversion_1.convertDocStringToPlainText)(docString));
|
454
477
|
}
|
455
478
|
else {
|
456
|
-
(0, debug_1.fail)(`Unsupported markup type: ${
|
479
|
+
(0, debug_1.fail)(`Unsupported markup type: ${this._format}`);
|
457
480
|
}
|
458
481
|
}
|
459
482
|
}
|
460
|
-
|
483
|
+
_addResultsPart(parts, text, python = false) {
|
461
484
|
parts.push({
|
462
485
|
python,
|
463
486
|
text,
|
464
487
|
});
|
465
488
|
}
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
(0, debug_1.fail)(`Unsupported markup type: ${format}`);
|
489
|
+
_convertHoverResults(hoverResults) {
|
490
|
+
if (!hoverResults) {
|
491
|
+
return undefined;
|
492
|
+
}
|
493
|
+
let markupString = hoverResults.parts
|
494
|
+
.map((part) => {
|
495
|
+
if (part.python) {
|
496
|
+
if (this._format === vscode_languageserver_1.MarkupKind.Markdown) {
|
497
|
+
return '```python\n' + part.text + '\n```\n';
|
498
|
+
}
|
499
|
+
else if (this._format === vscode_languageserver_1.MarkupKind.PlainText) {
|
500
|
+
return part.text + '\n\n';
|
501
|
+
}
|
502
|
+
else {
|
503
|
+
(0, debug_1.fail)(`Unsupported markup type: ${this._format}`);
|
504
|
+
}
|
483
505
|
}
|
506
|
+
return part.text;
|
507
|
+
})
|
508
|
+
.join('')
|
509
|
+
.trimEnd();
|
510
|
+
// If we have a lastKnownModule in the hover results, stick in a comment with
|
511
|
+
// the hashed module name. This is used by the other side to send telemetry.
|
512
|
+
if (hoverResults.lastKnownModule && this._format === vscode_languageserver_1.MarkupKind.Markdown && this._supportTelemetry) {
|
513
|
+
markupString += `\n<!--moduleHash:${(0, stringUtils_1.hashString)(hoverResults.lastKnownModule)}-->`;
|
484
514
|
}
|
485
|
-
return
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
markupString += `\n<!--moduleHash:${(0, stringUtils_1.hashString)(hoverResults.lastKnownModule)}-->`;
|
515
|
+
return {
|
516
|
+
contents: {
|
517
|
+
kind: this._format,
|
518
|
+
value: markupString,
|
519
|
+
},
|
520
|
+
range: hoverResults.range,
|
521
|
+
};
|
493
522
|
}
|
494
|
-
return {
|
495
|
-
contents: {
|
496
|
-
kind: format,
|
497
|
-
value: markupString,
|
498
|
-
},
|
499
|
-
range: hoverResults.range,
|
500
|
-
};
|
501
523
|
}
|
502
|
-
exports.
|
524
|
+
exports.HoverProvider = HoverProvider;
|
503
525
|
//# sourceMappingURL=hoverProvider.js.map
|