File tree Expand file tree Collapse file tree 4 files changed +15
-16
lines changed Expand file tree Collapse file tree 4 files changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ vscode extension for generate call graph in [graphviz dot language](https://www.
12121 . Open your folder and select a entry function
13132 . Run ` CallGraph.showOutgoingCallGraph ` command using ` Ctrl+Shift+P ` or context menu to show outgoing calls
14143 . Or Run ` CallGraph.showIncomingCallGraph ` command using ` Ctrl+Shift+P ` or context menu to show incoming calls
15+ 4 . Add ` .callgraphignore ` file in your project root directory to ignore some files or folders
1516
1617## How it works
1718It depends ` vscode.provideOutgoingCalls ` and ` vscode.provideIncomingCalls ` built-in commands.
Original file line number Diff line number Diff line change 6666 "@types/glob" : " ^7.2.0" ,
6767 "@types/mocha" : " ^9.1.0" ,
6868 "@types/node" : " 14.x" ,
69- "@types/picomatch" : " ^2.3.0" ,
7069 "@types/vscode" : " ^1.65.0" ,
7170 "@typescript-eslint/eslint-plugin" : " ^5.16.0" ,
7271 "@typescript-eslint/parser" : " ^5.16.0" ,
9291 " dot"
9392 ],
9493 "dependencies" : {
95- "picomatch " : " ^2.3.1 "
94+ "ignore " : " ^5.2.4 "
9695 }
97- }
96+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { generateDot } from './dot'
88import { getHtmlContent } from './html'
99import * as path from 'path'
1010import * as fs from 'fs'
11- import * as pm from 'picomatch '
11+ import ignore from 'ignore '
1212
1313export const output = vscode . window . createOutputChannel ( 'CallGraph' )
1414
@@ -53,13 +53,12 @@ const generateGraph = (
5353 if ( ignoreFile && ! fs . existsSync ( ignoreFile ) ) ignoreFile = null
5454 const graph = await callNodeFunction ( entry [ 0 ] , item => {
5555 if ( ignoreFile === null ) return false
56- const patterns = fs
57- . readFileSync ( ignoreFile )
58- . toString ( )
59- . split ( '\n' )
60- . filter ( str => str . length > 0 )
61- . map ( str => path . resolve ( workspace . fsPath , str ) )
62- return pm ( patterns ) ( item . uri . fsPath )
56+ // working in the current workspace
57+ if ( ! item . uri . fsPath . startsWith ( workspace . fsPath ) ) return true
58+ const ig = ignore ( ) . add ( fs . readFileSync ( ignoreFile ) . toString ( ) )
59+ const itemPath = item . uri . fsPath . replace ( `${ workspace . fsPath } /` , '' )
60+ const ignored = ig . test ( itemPath ) . ignored
61+ return ignored
6362 } )
6463
6564 generateDot ( graph , dotFile . fsPath )
Original file line number Diff line number Diff line change 9090 resolved "https://registry.npmmirror.com/@types/node/-/node-14.18.12.tgz#0d4557fd3b94497d793efd4e7d92df2f83b4ef24"
9191 integrity sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A==
9292
93- " @types/picomatch@^2.3.0 " :
94- version "2.3.0"
95- resolved "https://registry.npmmirror.com/@types/picomatch/-/picomatch-2.3.0.tgz#75db5e75a713c5a83d5b76780c3da84a82806003"
96- integrity sha512-O397rnSS9iQI4OirieAtsDqvCj4+3eY1J+EPdNTKuHuRWIfUoGyzX294o8C4KJYaLqgSrd2o60c5EqCU8Zv02g==
97-
9893" @types/vscode@^1.65.0 " :
9994 version "1.65.0"
10095 resolved "https://registry.npmmirror.com/@types/vscode/-/vscode-1.65.0.tgz#042dd8d93c32ac62cb826cd0fa12376069d1f448"
@@ -762,6 +757,11 @@ ignore@^5.1.8, ignore@^5.2.0:
762757 resolved "https://registry.npmmirror.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
763758 integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
764759
760+ ignore@^5.2.4 :
761+ version "5.2.4"
762+ resolved "https://registry.npmmirror.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
763+ integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==
764+
765765import-fresh@^3.0.0, import-fresh@^3.2.1 :
766766 version "3.3.0"
767767 resolved "https://registry.npmmirror.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
You can’t perform that action at this time.
0 commit comments