Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
"copy value" from variables debugger window not working #290
Conversation
|
Thanks for the contribution. The solution works well, except we need handle array/collection/map better. |
| referenceId = context.getRecyclableIdPool().addObject(containerNode.getThreadId(), varProxy); | ||
| evaluateName = varProxy.getEvaluateName(); |
testforstephen
Aug 21, 2019
•
Contributor
For the Collection and Map type, we did special handling to show their logical structure, so their display style looks like array.

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.
- 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.
- 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.
For the Collection and Map type, we did special handling to show their logical structure, so their display style looks like array.

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.
- 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 likemap.entrySet().toArray()[0]. - If the container is
java.util.Map$Entry, the evaluate name for the children is likemap.entrySet().toArray(new java.util.Map.Entry[0])[0].getKey().
The cons is the problem will become complex when the hierarchy is deep.
- The second solution is to disable
Copy Valueon the children of Map and Collection, only enable it on the Map and Collection itself, and return their toString value.
For example, when hover onmap, the copy operation should return{a=1}.
Similarly, when copy an array, we need return its toString() instead.
drungrin
Aug 21, 2019
Author
Contributor
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.
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.
testforstephen
Aug 22, 2019
Contributor
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.
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.
Fixes microsoft/vscode-java-debug#624