Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement - About adding the "jump to location" capability for Crabviz #48

Open
ccsyt1205 opened this issue Dec 3, 2024 · 1 comment

Comments

@ccsyt1205
Copy link

Dear author,
I installed the crabviz extension and I think it very useful for quickly reading code. It shows the graph clearly in a webview.
And I tried clicking the function node, but it seems that the extension doesn't offer the capability to jump to the location where the function node locates in source code. I want to enhance the extension.
I downloaded and browsed the source code of Crabviz VSCode extension. I come up with an idea.
The element in the graph of webview is "svg", so, I think if we add "file-location" attribute and "line-location" attribute, when user double click the svg of a function node, the webview could post a message containing the location info to the crabivz extension. And then crabviz extension could jump to the location using “vscode.workspace.openTextDocument”.
I encountered a problem that, I just couldn't find where you generate these svg and how to add the "file-location" attribute and "line-location" attribute to it,could you please help me figure out? Thank a lot!

@chanhx
Copy link
Owner

chanhx commented Dec 4, 2024

I’m glad it’s useful for you. Actually, I was working on this feature a few months ago (branch vscode-0.5.0), but the development was suspended due to other matters. In my approach, I add a bar on top of the call graph, so that we can perform operations there, like exporting the call graph, zooming in or out, searching symbols and jumping to definition. If a function is selected, its name will shown on the bar, and we can click a button on the bar to jump to definition. I had considered about double-clicking, but I think it’s not as noticeable as the top bar approach, users may not be aware of this feature until they double-click a function.

I encountered a problem that, I just couldn't find where you generate these svg and how to add the "file-location" attribute and "line-location" attribute to it,could you please help me figure out? Thank a lot!

I generate SVGs with the @viz-js/viz package. Firstly, I generate the dot string, and then pass it to viz to generate the SVG, and then modify the SVG to add some classes and ids. And actually in branch vscode-0.5.0, all the information you need is in the SVG. The file path is stored in the path attribute, and the cell id is consisted of the number of line and the number of column.

The development has resumed this month, but the progress is a bit slow because it involves some refactoring and new UI development.

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

No branches or pull requests

2 participants