Skip to content

Commit c472173

Browse files
committed
Add Context for getVariables, StoreMemory, and ApplyMemory
1 parent 522b39b commit c472173

6 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/common/messaging.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ export const setOptionsType: RequestType<MemoryOptions, void> = { method: 'setOp
6262
export const logMessageType: RequestType<string, void> = { method: 'logMessage' };
6363
export const readMemoryType: RequestType<[ReadMemoryArguments, Context?], ReadMemoryResult> = { method: 'readMemory' };
6464
export const writeMemoryType: RequestType<[WriteMemoryArguments, Context?], WriteMemoryResult> = { method: 'writeMemory' };
65-
export const getVariablesType: RequestType<ReadMemoryArguments, VariableRange[]> = { method: 'getVariables' };
66-
export const storeMemoryType: RequestType<StoreMemoryArguments, void> = { method: 'storeMemory' };
67-
export const applyMemoryType: RequestType<ApplyMemoryArguments, ApplyMemoryResult> = { method: 'applyMemory' };
65+
export const getVariablesType: RequestType<[ReadMemoryArguments, Context?], VariableRange[]> = { method: 'getVariables' };
66+
export const storeMemoryType: RequestType<[StoreMemoryArguments, Context?], void> = { method: 'storeMemory' };
67+
export const applyMemoryType: RequestType<[ApplyMemoryArguments, Context?], ApplyMemoryResult> = { method: 'applyMemory' };
6868

6969
export const showAdvancedOptionsType: NotificationType<void> = { method: 'showAdvancedOptions' };
7070
export const getWebviewSelectionType: RequestType<void, WebviewSelection> = { method: 'getWebviewSelection' };

src/plugin/adapter-registry/adapter-capabilities.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import { Logger } from '../logger';
2424
/** Represents capabilities that may be achieved with particular debug adapters but are not part of the DAP */
2525
export interface AdapterCapabilities {
2626
/** Resolve variables known to the adapter to their locations. Fallback if {@link getResidents} is not present */
27-
getVariables?(session: vscode.DebugSession): Promise<VariableRange[]>;
27+
getVariables?(session: vscode.DebugSession, context?: Context): Promise<VariableRange[]>;
2828
/** Resolve symbols resident in the memory at the specified range. Will be preferred to {@link getVariables} if present. */
29-
getResidents?(session: vscode.DebugSession, params: DebugProtocol.ReadMemoryArguments): Promise<VariableRange[]>;
29+
getResidents?(session: vscode.DebugSession, params: DebugProtocol.ReadMemoryArguments, context?: Context): Promise<VariableRange[]>;
3030
/** Resolves the address of a given variable in bytes withthe current context. */
31-
getAddressOfVariable?(session: vscode.DebugSession, variableName: string): Promise<string | undefined>;
31+
getAddressOfVariable?(session: vscode.DebugSession, variableName: string, context?: Context): Promise<string | undefined>;
3232
/** Resolves the size of a given variable in bytes within the current context. */
33-
getSizeOfVariable?(session: vscode.DebugSession, variableName: string): Promise<bigint | undefined>;
33+
getSizeOfVariable?(session: vscode.DebugSession, variableName: string, context?: Context): Promise<bigint | undefined>;
3434
initializeAdapterTracker?(session: vscode.DebugSession): vscode.DebugAdapterTracker | undefined;
3535
getContexts?(session: vscode.DebugSession): Promise<Context[]>;
3636
readMemory?(session: vscode.DebugSession, params: ReadMemoryArguments, context?: Context): Promise<ReadMemoryResult>;

src/plugin/memory-provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ export class MemoryProvider {
179179
});
180180
}
181181

182-
public async getVariables(variableArguments: DebugProtocol.ReadMemoryArguments): Promise<VariableRange[]> {
182+
public async getVariables([variableArguments, context]: ReadMemoryWithContext): Promise<VariableRange[]> {
183183
const session = this.assertActiveSession('get variables');
184184
const handler = this.adapterRegistry?.getHandlerForSession(session.type);
185-
if (handler?.getResidents) { return handler.getResidents(session, variableArguments); }
186-
return handler?.getVariables?.(session) ?? [];
185+
if (handler?.getResidents) { return handler.getResidents(session, variableArguments, context); }
186+
return handler?.getVariables?.(session, context) ?? [];
187187
}
188188

189189
public async getAddressOfVariable(variableName: string): Promise<string | undefined> {

src/plugin/memory-webview-main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
291291
}
292292
}
293293

294-
protected async getVariables(request: ReadMemoryArguments): Promise<VariableRange[]> {
294+
protected async getVariables(request: [ReadMemoryArguments, Context?]): Promise<VariableRange[]> {
295295
try {
296296
return await this.memoryProvider.getVariables(request);
297297
} catch (err) {
@@ -316,7 +316,7 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
316316
this.setMemoryViewSettings(ctx.messageParticipant, { visibleColumns });
317317
}
318318

319-
protected async storeMemory(storeArguments: StoreMemoryArguments): Promise<void> {
319+
protected async storeMemory(storeArguments: [StoreMemoryArguments, Context?]): Promise<void> {
320320
// Even if we disable the command in VS Code through enablement or when condition, programmatic execution is still possible.
321321
// However, we want to fail early in case the user tries to execute a disabled command
322322
if (!this.memoryProvider.createContext().canRead) {

src/webview/memory-webview-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class App extends React.Component<{}, MemoryAppState> {
336336
}
337337

338338
protected storeMemory = async (): Promise<void> => {
339-
await messenger.sendRequest(storeMemoryType, HOST_EXTENSION, { ...this.state.activeReadArguments });
339+
await messenger.sendRequest(storeMemoryType, HOST_EXTENSION, [{ ...this.state.activeReadArguments }, this.state.context]);
340340
};
341341

342342
protected applyMemory = async (): Promise<void> => {

src/webview/variables/variable-decorations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class VariableDecorator implements ColumnContribution, Decorator {
4848

4949
async fetchData(currentViewParameters: ReadMemoryArguments): Promise<void> {
5050
if (!this.active || !currentViewParameters.memoryReference || !currentViewParameters.count) { return; }
51-
const visibleVariables = (await messenger.sendRequest(getVariablesType, HOST_EXTENSION, currentViewParameters))
51+
const visibleVariables = (await messenger.sendRequest(getVariablesType, HOST_EXTENSION, [currentViewParameters, undefined]))
5252
.map<BigIntVariableRange>(transmissible => {
5353
const startAddress = BigInt(transmissible.startAddress);
5454
return {

0 commit comments

Comments
 (0)