-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add children roSGNode containers (#192)
* Add children to the children of roSGNode containers. Make the evaluation of temparory variables a helper function * Fix lint issues * Move lint fixes * Rename evalutTemporaryVariables to evaluateExpressionToTempVar * Add the [[count]] value to the variables debug panel * Fix unit test * Change counts type to "number" and make it greyed out with the "virtual" presentationHint * Allow name to be a string or number when creating containers * Set the [[count]] to zero if there are no elements and the type is "Array" * Move logic for adding new variables into a helper file / function * Return the container object * Change the gate keeping logic to a nested if block instead of an early out if check * Use $ instead of [[ ]] * Add clarity to a test why a `2` showed up * Fix some lint errors in loops * Rename `insertCustomVariablesHelpers` and make it async * Make `createEvaluateContainer` `name` only accept a string * Rename custom variable utils file * Revert integer thing. * Add unit tests for createEvaulateContainer with different children types * Add clarifying comment --------- Co-authored-by: Bronley Plumb <[email protected]>
- Loading branch information
1 parent
41e5157
commit cc32b3c
Showing
4 changed files
with
140 additions
and
32 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
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,40 @@ | ||
import * as semver from 'semver'; | ||
import { KeyType } from './DebugProtocolAdapter'; | ||
import type { DebugProtocolAdapter, EvaluateContainer } from './DebugProtocolAdapter'; | ||
|
||
/** | ||
* Insert custom variables into the `EvaluateContainer`. Most of these are for compatibility with older versions of the BrightScript debug protocol, | ||
* but occasionally can be for adding new functionality for properties that don't exist in the debug protocol. Some of these will run `evaluate` commands | ||
* to look up the data for the custom variables. | ||
*/ | ||
export async function insertCustomVariables(adapter: DebugProtocolAdapter, expression: string, container: EvaluateContainer): Promise<void> { | ||
if (semver.satisfies(adapter?.activeProtocolVersion, '<3.3.0')) { | ||
if (container?.value?.startsWith('roSGNode')) { | ||
let nodeChildren = <EvaluateContainer>{ | ||
name: '$children', | ||
type: 'roArray', | ||
highLevelType: 'array', | ||
keyType: KeyType.integer, | ||
presentationHint: 'virtual', | ||
evaluateName: `${expression}.getChildren(-1, 0)`, | ||
children: [] | ||
}; | ||
container.children.push(nodeChildren); | ||
} | ||
if (container.elementCount > 0 || container.type === 'Array') { | ||
let nodeCount = <EvaluateContainer>{ | ||
name: '$count', | ||
evaluateName: container.elementCount.toString(), | ||
type: 'number', | ||
highLevelType: undefined, | ||
keyType: undefined, | ||
presentationHint: 'virtual', | ||
value: container.elementCount.toString(), | ||
elementCount: undefined, | ||
children: [] | ||
}; | ||
container.children.push(nodeCount); | ||
} | ||
} | ||
await Promise.resolve(); | ||
} |
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