<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 14, 2020 at 6:10 PM Kadir Cetinkaya via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">kadircet added a comment.<br>
<br>
In D89277#2329947 <<a href="https://reviews.llvm.org/D89277#2329947" rel="noreferrer" target="_blank">https://reviews.llvm.org/D89277#2329947</a>>, @sammccall wrote:<br>
<br>
> (sorry out today and haven't looked at code yet)<br>
<br>
no worries it is a prototype, I wouldn't spend time looking at the implementation until we agree on the interaction :D<br>
OTHO, checking out the lit test for output would probably be useful.<br>
<br>
> If it's a custom method, I think it should return the data as a json structure - the client already has to have custom support to invoke it, displaying the result isn't much extra work.<br>
<br>
SGTM. WDYT about a json object in the form of:<br>
<br>
  interface MemoryTreeNode {<br>
    name: string;<br>
    totalSize: int;<br></blockquote><div>I'd also include self-size.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
    children?: Node[];<br>
  };<br></blockquote><div>This looks like:</div><div>{</div><div>  "name": "root"</div><div>  "totalSize": 100,</div><div>  "children": [</div><div>    {</div><div>      "name": "component1",</div><div>      "totalSize": 25,</div><div>    },</div><div>    {</div><div>      "name": "component2",</div><div>      "totalSize": 75,</div><div>    }</div><div></div><div>  ]</div><div>}</div><div> </div><div>A couple of alternatives: I think making "children" an object and moving the name up to the edge is more natural.</div><div>We no longer name the root, which I don't think is a bad thing.</div><div><div>{</div><div>  "totalSize": 100,<br></div><div>  "children": {</div><div>    "component1": {<br></div><div>      "totalSize": 25,</div><div>    },</div><div>    "component2": {</div><div>      "totalSize": 75,</div><div>    }</div><div></div><div>  ]</div><div>}</div></div><div><br></div><div>A more-compact alternative folds the child attributes into the node itself.</div><div>This is probably more awkward to query directly (e.g. "does a node have children") and might end up being marshalled into a struct.</div><div>On the other hand, I think it's easier to read directly e.g. in logs, esp when deeply nested.</div><div>{</div><div>  "_total": 100,<br></div><div>  "component1": {</div><div>    "_total": 25<br></div><div>  }</div><div>  "component2": {</div><div>    "_total": 25<br></div><div>  }</div><div>}</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> And I would really love to add a tree view to vscode, I think it wouldn't be hard (vs call hierarchy: no laziness and no direction-flipping) and could be reused for an AST viewer.<br>
<br>
right, vscode already has APIs for it, <a href="https://code.visualstudio.com/api/extension-guides/tree-view" rel="noreferrer" target="_blank">https://code.visualstudio.com/api/extension-guides/tree-view</a>.<br></blockquote><div>I found some time today and have a prototype of AST dump... nearly working :-)</div><div>The complexity of the treeview API does indeed mostly disappear when you have simple tree-shaped data and it's all available at once.</div><div>Just the annoying extension-point boilerplate remains...</div></div></div>