This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override the variables retrieval and mutation logic for EDP.
- Loading branch information
1 parent
456613a
commit 6c242c1
Showing
2 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {DebugProtocol} from 'vscode-debugprotocol'; | ||
import {logger, variables, Crdp, utils as coreUtils} from 'vscode-chrome-debug-core'; | ||
import {localize, EdgeDebugAdapter} from './edgeDebugAdapter'; | ||
|
||
interface EdgeDebugClient extends Crdp.DebuggerClient { | ||
msSetDebuggerPropertyValue(payload: { | ||
debuggerPropertyId: string, | ||
newValue: string | ||
}): Promise<{}>; | ||
} | ||
|
||
export interface ExtendedDebugProtocolVariable extends DebugProtocol.Variable { | ||
msDebuggerPropertyId?: string; | ||
} | ||
|
||
export class MSPropertyContainer extends variables.BaseVariableContainer { | ||
private _childPropertiesMapping: { | ||
[propertyName: string]: string | ||
} | ||
|
||
public constructor(objectId: string, evaluateName?: string) { | ||
super(objectId, evaluateName); | ||
|
||
this._childPropertiesMapping = {}; | ||
} | ||
|
||
public async expand(adapter: EdgeDebugAdapter, filter?: string, start?: number, count?: number): Promise<DebugProtocol.Variable[]> { | ||
let variables = await super.expand(adapter, filter, start, count); | ||
|
||
for( let variable of variables) { | ||
let extendedVarialbe = variable as ExtendedDebugProtocolVariable; | ||
|
||
if (extendedVarialbe.msDebuggerPropertyId) { | ||
this._childPropertiesMapping[variable.name] = extendedVarialbe.msDebuggerPropertyId; | ||
|
||
// Also remove the additional field from `variable`, so it will not appear when report to PineZorro/VS Code | ||
delete extendedVarialbe.msDebuggerPropertyId; | ||
} | ||
} | ||
return variables; | ||
} | ||
|
||
public async setValue(adapter: EdgeDebugAdapter, name: string, value: string): Promise<string> { | ||
const msDebuggerPropertyId = this._childPropertiesMapping[name]; | ||
|
||
if (!msDebuggerPropertyId) { | ||
logger.error(`Cannot find msDebuggerPropertyId for {name}`); | ||
throw coreUtils.errP(localize("edge.debug.error.notFoundMsDebuggerPropertyId", "Cannot find msDebuggerPropertyId for a property.")); | ||
} | ||
|
||
const edgeDebugClient: EdgeDebugClient = adapter.chrome.Debugger as EdgeDebugClient; | ||
|
||
let result = await edgeDebugClient.msSetDebuggerPropertyValue({ | ||
"debuggerPropertyId": msDebuggerPropertyId, | ||
"newValue": value | ||
}); | ||
|
||
return value; | ||
} | ||
} |