Skip to content

Commit 9b10e18

Browse files
add inlineProvider
1 parent 2ea86b1 commit 9b10e18

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

src/extension/debugger/inlineValue/pythonInlineValueProvider.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,34 @@ export class PythonInlineValueProvider implements InlineValuesProvider {
1010

1111
public async provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext): Promise<InlineValue[]> {
1212
console.log("inline provider");
13-
let variables = await resolveInlineVariables({
14-
uri: document.uri.toString(),
15-
viewPort: viewPort,
16-
stoppedLocation: context.stoppedLocation,
17-
});
13+
let a = JSON.stringify(context);
14+
const allValues: InlineValue[] = [];
15+
16+
for (let l = 0; l <= context.stoppedLocation.end.line; l++) {
17+
const line = document.lineAt(l);
18+
var re = /\b[a-zA-Z_][a-zA-Z0-9_]*\b/g;
19+
do {
20+
var m = re.exec(line.text);
21+
if (m) {
22+
const varName = m[0];
23+
const rng = new Range(l, m.index, l, m.index + varName.length);
24+
25+
//allValues.push(new vscode.InlineValueText(r, `${varName}: some value`));
26+
allValues.push(new InlineValueVariableLookup(rng, varName));
27+
//allValues.push(new vscode.InlineValueEvaluatableExpression(r, varName));
28+
}
29+
} while (m);
30+
}
31+
32+
return allValues;
33+
// let variables = await resolveInlineVariables({
34+
// uri: document.uri.toString(),
35+
// viewPort: viewPort,
36+
// stoppedLocation: context.stoppedLocation,
37+
// });
38+
1839
return [];
1940
}
20-
2141
}
2242

2343
// tslint:disable-next-line:interface-name
@@ -43,5 +63,6 @@ export interface InlineVariable {
4363
}
4464

4565
export async function resolveInlineVariables(inlineParams: InlineParams): Promise<InlineVariable[]> {
46-
return <InlineVariable[]> await executeCommand("vscode.python.resolveInlineVariables", JSON.stringify(inlineParams));
47-
}
66+
debug.startDebugging;
67+
return <InlineVariable[]> await executeCommand("vscode.debug.resolveInlineVariables", JSON.stringify(inlineParams));
68+
}

src/extension/extensionInit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { openReportIssue } from './common/application/commands/reportIssueComman
4949
import { buildApi } from './api';
5050
import { IExtensionApi } from './apiTypes';
5151
import { registerHexDebugVisualizationTreeProvider } from './debugger/visualizers/inlineHexDecoder';
52+
import { PythonInlineValueProvider } from './debugger/inlineValue/pythonInlineValueProvider';
5253

5354
export async function registerDebugger(context: IExtensionContext): Promise<IExtensionApi> {
5455
const childProcessAttachService = new ChildProcessAttachService();
@@ -136,6 +137,7 @@ export async function registerDebugger(context: IExtensionContext): Promise<IExt
136137
context.subscriptions.push(
137138
debug.registerDebugAdapterDescriptorFactory(DebuggerTypeName, debugAdapterDescriptorFactory),
138139
);
140+
139141
context.subscriptions.push(
140142
debug.onDidStartDebugSession((debugSession) => {
141143
const shouldTerminalFocusOnStart = getConfiguration('python', debugSession.workspaceFolder?.uri)?.terminal
@@ -206,5 +208,7 @@ export async function registerDebugger(context: IExtensionContext): Promise<IExt
206208
}),
207209
);
208210

211+
context.subscriptions.push(languages.registerInlineValuesProvider({language: 'python'}, new PythonInlineValueProvider()));
212+
209213
return buildApi();
210214
}

0 commit comments

Comments
 (0)