File tree Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Expand file tree Collapse file tree 4 files changed +15
-10
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 9292 " dot"
9393 ],
9494 "dependencies" : {
95- "picomatch " : " ^2.3.1 "
95+ "ignore " : " ^5.2.4 "
9696 }
97- }
97+ }
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 @@ -762,6 +762,11 @@ ignore@^5.1.8, ignore@^5.2.0:
762762 resolved "https://registry.npmmirror.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
763763 integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
764764
765+ ignore@^5.2.4 :
766+ version "5.2.4"
767+ resolved "https://registry.npmmirror.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
768+ integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==
769+
765770import-fresh@^3.0.0, import-fresh@^3.2.1 :
766771 version "3.3.0"
767772 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