Skip to content

Commit 2ea86b1

Browse files
Add inline provider
1 parent eb0d1ec commit 2ea86b1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
import { commands, debug, InlineValue, InlineValueContext, InlineValueEvaluatableExpression, InlineValuesProvider, InlineValueText, InlineValueVariableLookup,
5+
Range, TextDocument } from "vscode";
6+
import { executeCommand } from "../../common/vscodeapi";
7+
8+
9+
export class PythonInlineValueProvider implements InlineValuesProvider {
10+
11+
public async provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext): Promise<InlineValue[]> {
12+
console.log("inline provider");
13+
let variables = await resolveInlineVariables({
14+
uri: document.uri.toString(),
15+
viewPort: viewPort,
16+
stoppedLocation: context.stoppedLocation,
17+
});
18+
return [];
19+
}
20+
21+
}
22+
23+
// tslint:disable-next-line:interface-name
24+
export interface InlineParams {
25+
uri: string;
26+
viewPort?: Range;
27+
stoppedLocation: Range;
28+
}
29+
30+
// tslint:disable-next-line:interface-name
31+
export enum InlineKind {
32+
VariableLookup = 0,
33+
Evaluation = 1,
34+
}
35+
36+
// tslint:disable-next-line:interface-name
37+
export interface InlineVariable {
38+
range: Range;
39+
name: string;
40+
kind: InlineKind;
41+
expression: string;
42+
declaringClass: string;
43+
}
44+
45+
export async function resolveInlineVariables(inlineParams: InlineParams): Promise<InlineVariable[]> {
46+
return <InlineVariable[]> await executeCommand("vscode.python.resolveInlineVariables", JSON.stringify(inlineParams));
47+
}

0 commit comments

Comments
 (0)