rokucommunity / roku-debug

A compatibility wrapper around the BrightScript debug protocol https://developer.roku.com/en-ca/docs/developer-program/debugging/socket-based-debugger.md
MIT License
13 stars 9 forks source link

Show [[count]] var for arrays #136

Open TwitchBronBron opened 1 year ago

TwitchBronBron commented 1 year ago

In the debug protocol, we know the length of the array ahead of time, so we should show the [[count]] variable. Code like this would work:

v.namedVariables = 1;

//add a virtual [[count]] prop if the array children are present
if (result.children && result.children?.length === result?.elementCount && result?.elementCount === 3) {
    v.childVariables.push(
        this.getVariableFromResult({
            name: '[[count]]',
            value: result?.elementCount.toString(),
            type: 'integer',
            highLevelType: HighLevelType.primative,
            evaluateName: `${result.evaluateName}.count()`,
            presentationHint: 'virtual',
            keyType: undefined,
            children: undefined,
            elementCount: 0
        }, frameId)
    );
}

The issue right now, is for arrays, we end up with both indexed and named variables, so our variable lookup pipelines don't currently support splitting them out between the two. So that'll need done too.