GithubHelp home page GithubHelp logo

chanhx / crabviz Goto Github PK

View Code? Open in Web Editor NEW
585.0 8.0 17.0 524 KB

🦀 A LSP-based interative call graph generator

License: Apache License 2.0

Rust 47.46% JavaScript 13.56% CSS 4.80% TypeScript 34.18%
static-analysis lsp language-server-protocol cpp go java javascript python typescript rust c callgraph vscode

crabviz's Introduction

Crabviz

Crabviz is a LSP-based call graph generator. It leverages the Language Server Protocol to generate interactive call graphs, helps you visually explore source code.

Features

  • Workable for various programming languages

  • Highlight on click

  • Two kinds of graphs

    You can generate a call graph for selected files to get an overview, or a selected function to track the call hierarchy.

  • Export call graphs as SVG

Preview

preview

Install

Since Crabviz utilizes the capabilities of language servers, it is better suited as an IDE/editor extension than a standalone command line tool.

It is currently available on VS Code, and PRs for other editors are welcome.

Credits

Crabviz is inspired by graphql-voyager and go-callvis.

crabviz's People

Contributors

chanhx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crabviz's Issues

Error in language detection

I want to show graphviz about cranelift, but found error as follow.

I don't know exactly why. Can you take a look for me?

2023-12-28 22:52:16.484 [error] Error: command failed with error code 2: error parsing glob '!/{**/*.css,**/*.csv,**/*.gif,**/*.gitignore,**/*.html,**/*.md,**/*.jpeg,**/*.jpg,**/*.json,**/*.lex,**/*.lock,**/*.log,**/*.png,**/*.toml,**/*.txt,**/*.xml,**/*.yaml,**/*.yacc,**/*.yml,fuzz/artifacts,fuzz/corpus,benches/wasi/test.bin,benches/instantiation/wasi.wasm,*.bk,*.pyc,*.swo,*.swp,*.swx,*~,.*.rustfmt,.mypy_cache,/#*/#,cranelift.dbg*,docs/_build,docs/book,.vscode/,.vs/,rusty-tags.*,tags,target,.z3-trace,foo,.cargo,publish,vendor,examples/build,examples/.cache,*.coredump,docs/assemblyscript-hello-world/node_modules/,docs/assemblyscript-hello-world/package-lock.json,docs/assemblyscript-hello-world/*.lock,docs/assemblyscript-hello-world/*.{wat,wasm},docs/assemblyscript_demo/node_modules/,docs/assemblyscript_demo/package-lock.json,docs/assemblyscript_demo/*.lock,docs/assemblyscript_demo/*.{wat,wasm},crates/wasi-common/WASI/*.bk,crates/wasi-common/WASI/*.swp,crates/wasi-common/WASI/*.swo,crates/wasi-common/WASI/*.swx,crates/wasi-common/WASI/tags,crates/wasi-common/WASI/target,crates/wasi-common/WASI/Cargo.lock,crates/wasi-common/WASI/.*.rustfmt,crates/wasi-common/WASI/rusty-tags.*,crates/wasi-common/WASI/*~,crates/wasi-common/WASI//#*/#,crates/wasi-common/WASI/tools/witx/target,crates/wasi-common/WASI/tools/witx/Cargo.lock,crates/c-api/html,crates/c-api/wasm-c-api/out,crates/c-api/wasm-c-api/v8,crates/environ/target/,crates/environ/**/*.rs.bk,crates/environ/Cargo.lock,crates/environ/fuzz/corpus,crates/environ/fuzz/artifacts,crates/bench-api/stdout.log,crates/bench-api/stderr.log,crates/fuzzing/wasm-spec-interpreter/ocaml/_build,crates/fuzzing/wasm-spec-interpreter/ocaml/spec,cranelift/isle/target,cranelift/isle/*~,cranelift/isle/.*.swp,cranelift/isle/fuzz/target,cranelift/isle/fuzz/corpus,cranelift/isle/fuzz/artifacts,cranelift/docs/_build,tests/wasi_testsuite/wasi-common/tests/rust/target/,tests/wasi_testsuite/wasi-common/tests/assemblyscript/node_modules/,tests/spec_testsuite/commit_message,tests/spec_testsuite/repos/,tests/wasi_testsuite/wasi-threads/test/testsuite/*.wasm,tests/wasi_testsuite/wasi-common/*.wasm,tests/wasi_testsuite/wasi-common/.DS_Store,tests/wasi_testsuite/wasi-common/test-runner/__pycache__/,tests/wasi_testsuite/wasi-common/test-runner/.coverage,tests/wasi_testsuite/wasi-common/tests/c/testsuite/fs-tests.dir/writeable/*,tests/wasi_testsuite/wasi-common/tests/c/testsuite/fs-tests.dir/writeable/!.gitignore}': nested alternate groups are not allowed

    at T (vscode-file://vscode-app/Users/huangzheng/Desktop/Visual%20Studio%20Code%202.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1861:5893)
    at vscode-file://vscode-app/Users/huangzheng/Desktop/Visual%20Studio%20Code%202.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1869:4355
    at async vscode-file://vscode-app/Users/huangzheng/Desktop/Visual%20Studio%20Code%202.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1869:2925 crabviz.generateCallGraph {"value":"chanhx.crabviz","_lower":"chanhx.crabviz"}

Tree view

Cool use of the LSP! It would be much more useful to me if it was possible to display in a tree (-like) layout instead of blocks for each file.

Doesn't Identify Calls Through Actix Route

Neat extension, I went to test it on some stuff I had lying around and noticed that it didn't identify functions that were called as routes for Actix. I have a repo that I was using while working through Zero to Production in Rust that I used to test.

I found that when looking at the graph for the entire src folder, it shows that my functions for routes are never called:

image

When checking the call hierarchy in VS Code, it correctly shows that this health_check function is called by run, which is called by spawn_app and main:

image

Source is here for reference: https://github.com/Torsitano/zero-to-rust/blob/main/src/routes/health_check.rs

Can't zoom in far enough

In a project at work, the call graph probably has several thousand items (we have et least 800 elixir modules).

When initially created the graph is just a thin vertical line, after maximally zooming in, it is a bold vertical line created from blocks, that seem to have labels. It is still not quite usable.

I have not yet been able to try this on smaller projects or comperably large projects in another language.

image

URI error in Windows

My project is designed with unity build methodology, meaning that everything gets compiled from a single source file. This seems to break crabviz. Example from "Extension Host" log when I try to parse my project folder:

2024-03-01 18:38:52.317 [error] Error: [UriError]: Scheme contains illegal characters.
	at v (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:96:31508)
	at new k (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:96:32708)
	at w (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:96:34346)
	at k.parse (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:96:33200)
	at e.FileClassifier.classifyFilesInDirectory (c:\Users\conra\.vscode\extensions\chanhx.crabviz-0.3.2\dist\extension.js:1:107033)
	at async e.FileClassifier.classifyFilesByLanguage (c:\Users\conra\.vscode\extensions\chanhx.crabviz-0.3.2\dist\extension.js:1:106556) crabviz.generateCallGraph {"value":"chanhx.crabviz","_lower":"chanhx.crabviz"}

My compile_commands.json:

[ 
{ "directory": "W:\\hi\\build", "file": "..\\code\\game\\game_main.cpp", "output": "C:\\Users\\conra\\AppData\\Local\\Temp\\game_main-11638f.o", "arguments": ["C:\\Program Files\\LLVM\\bin\\clang++.exe", "-xc++", "..\\code\\game\\game_main.cpp", "-o", "C:\\Users\\conra\\AppData\\Local\\Temp\\game_main-11638f.o", "--driver-mode=g++", "-g", "-O0", "-I", "..\\code\\", "-I", "..\\code\\3rdparty", "-std=c++20", "-D", "WIN32", "-D", "_WINDOWS", "-D", "_HAS_EXCEPTIONS=0", "-D", "_CRT_SECURE_NO_WARNING", "-fno-exceptions", "-fno-rtti", "-ferror-limit=0", "-Wall", "-Wextra", "-Werror", "-Wno-format", "-Wno-pragma-once-outside-header", "-Wno-gcc-compat", "-Wno-missing-field-initializers", "-Wno-missing-braces", "-Wno-unused-function", "-fsanitize=undefined", "-fno-omit-frame-pointer", "-fuse-ld=lld-link", "-Wl,/MANIFEST:EMBED,/INCREMENTAL:NO,C:\\Program Files\\LLVM\\lib\\clang\\18\\lib\\windows\\clang_rt.ubsan_standalone-x86_64.lib,C:\\Program Files\\LLVM\\lib\\clang\\18\\lib\\windows\\clang_rt.ubsan_standalone_cxx-x86_64.lib", "-dumpdir", "game.exe-", "--target=x86_64-pc-windows-msvc19.38.33134"]}
]

And here's the project: Project. Simply try to parase the code/ directory to reproduce.

Export interactive crabviz page

Thanks for the utility!
I want to export the crabviz page entirely as html (including the click functionality) as well as reference the links to the code in an online browser. Can you please consider this feature request?

Cannot parse generic parameters

impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryIterationCursor<'w, 's, Q, F> {
fetch: Q::clone_fetch(&self.fetch), //<<<
filter: F::clone_fetch(&self.filter),//<<<

Cannot find a directed edge from some function to clone_fetch.

feat: multi-select call flows

Is there a capability to do multi-select call flows? After generating the graph, the idea is to make some call flows stand out by making them brighter and the others less visible by clicking on just the flows that the user is interested in. It would be great to see this.

Only function names without directed segments

I have tried this plug-in several times with different java projects, and the generated results are only the functions in the project, and there is no calling relationship between functions, that is, directed line segments.I'm desperate to know what's causing this.
Uploading pic.PNG…

Does not seem to work with Python3

Looks amazing! But, Does this work with Python3? I get "no matching workspace symbols" errors. I think these were due to my init.py files which I deleted. However, no image is opening in vscode. Any ideas on how to get it working? Would be much appreciated :)

panic while generating a call graph

there is a panic while generating a call graph:

Panic context:
> 
version: 0.3.1631-standalone (83b3ba1b8 2023-08-19)
request: callHierarchy/outgoingCalls CallHierarchyOutgoingCallsParams {
    item: CallHierarchyItem {
        name: "output_record_batch_and_reset",
        kind: Function,
        tags: None,
        detail: Some(
            "fn output_record_batch_and_reset(&mut self) -> Result<RecordBatch>",
        ),
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/Users/r4ntix/Workspace/github/arrow-datafusion/datafusion/core/src/physical_plan/joins/sort_merge_join.rs",
            query: None,
            fragment: None,
        },
        range: Range {
            start: Position {
                line: 1242,
                character: 4,
            },
            end: Position {
                line: 1249,
                character: 5,
            },
        },
        selection_range: Range {
            start: Position {
                line: 1242,
                character: 7,
            },
            end: Position {
                line: 1242,
                character: 36,
            },
        },
        data: None,
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at 'invalid offset', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/line-index-0.1.0-pre.1/src/lib.rs:148:35
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: rust_analyzer::to_proto::range
   4: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   5: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
   6: rust_analyzer::handlers::request::handle_call_hierarchy_outgoing
   7: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 17:33:17] Request callHierarchy/outgoingCalls failed.
  Message: request handler panicked: invalid offset
  Code: -32603 

询问

对项目很感兴趣,可否一起开发

Previewing exported svg

After exporting call graph, can we preview again with crabviz extension? Because other svg extensions i tried are not interactable.

CrabViz not showing graph

I'm trying to run CrabViz, and I'm not getting a visualization. I do the following:

  1. right-click a directory on the left hand nav
  2. Click "CrabViz: generate call graph"

And nothing happens. CrabViz does briefly pop up with "loading languages" but that's about it.

I'm happy to debug, but not sure about how to do so. Are there instructions on how to do so?

I'm using VSCode with the SSH plugin, if that changes anything.

For better experience for usage

When I click on an item, it becomes relevant only to that item.
But if I click on a blank space (or scroll the canvas), it becomes all relevant.

Here are some ideas:

  • Lock
    If I can right-click or something .To make the canvas lock only one item,
  • Change the canvas by double-clicking
    make clicking the blank canvas doesn't become all relevant.
    Or double-click directly to change the interface
  • Or allow the keyboard to move the canvas to make mouse or touch is no need.

当我点击一项时,它变为只会这一项有关.
但如果我点空白的地方(或者拉动画布),就会变为全部相关.
我有一些想法:

  • 锁定
    如果可以右键或别的方法,来让界面锁定只有一项,
  • 变化界面通过双击
    暂时让点空白画布不会变为全部相关.或者直接双击才对界面有变化
  • 或者支持键盘移动画布
  • 而避免 要移动画布时, 鼠标或触摸对界面改变.

这可能是#9的一个复制

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.