Skip to content

"copy value" from variables debugger window not working#290

Closed
drungrin wants to merge 1 commit into
microsoft:masterfrom
drungrin:#624
Closed

"copy value" from variables debugger window not working#290
drungrin wants to merge 1 commit into
microsoft:masterfrom
drungrin:#624

Conversation

@drungrin
Copy link
Copy Markdown
Contributor

@msftclas
Copy link
Copy Markdown

msftclas commented Aug 20, 2019

CLA assistant check
All CLA requirements met.

Copy link
Copy Markdown
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. The solution works well, except we need handle array/collection/map better.

VariableProxy varProxy = new VariableProxy(containerNode.getThread(), containerNode.getScope(), value);
VariableProxy varProxy = new VariableProxy(containerNode.getThread(), containerNode.getScope(), value, containerNode, javaVariable.name);
referenceId = context.getRecyclableIdPool().addObject(containerNode.getThreadId(), varProxy);
evaluateName = varProxy.getEvaluateName();
Copy link
Copy Markdown
Contributor

@testforstephen testforstephen Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the Collection and Map type, we did special handling to show their logical structure, so their display style looks like array.
image

Currently when you hover on 0: HashMap$Node@64, and click Copy Value, the generated evaluateName is map.0. Evaluate engine will report Cannot evaluate because of compilation error(s): Syntax error on token ".0", delete this token..

There are two solutions in my mind.

  1. The first solution is to generate the correct evaluate name. That means we need handle the evaluate name specially for the type java.util.Map, java.util.Collection, java.util.Map$Entry.
  • If the container is java.util.Map, the evaluate name for the children is like map.entrySet().toArray()[0].
  • If the container is java.util.Map$Entry, the evaluate name for the children is like map.entrySet().toArray(new java.util.Map.Entry[0])[0].getKey().

The cons is the problem will become complex when the hierarchy is deep.

  1. The second solution is to disable Copy Value on the children of Map and Collection, only enable it on the Map and Collection itself, and return their toString value.
    For example, when hover on map, the copy operation should return {a=1}.

Similarly, when copy an array, we need return its toString() instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the first solution, when the hiearchy is deep, the evaluateName is already complex, in my opinion this isn't an issue.

I really dont like the second solution.

So, if you agree, I'll implement the solution 1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In solution 1, it may be a little tricky for generating the correct evaluate expression for Collection type. For example, in order to copy the nth element's children, the evaluate expression is like collection.toArray()[n].x, this will report compilation error because of java type check.

@testforstephen
Copy link
Copy Markdown
Contributor

@drungrin thanks for the initial PR, close it with another PR #338

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"copy value" from variables debugger window not working

3 participants