From a71562b7d9d71646b5b50aba862dcb339ad6d2f6 Mon Sep 17 00:00:00 2001 From: Khiem Doan Date: Thu, 19 Mar 2026 11:14:38 +0700 Subject: [PATCH] Use official package Signed-off-by: Khiem Doan --- go.mod | 62 ++++----- go.sum | 239 ++++++++++++++++++----------------- internal/graph/types.go | 6 +- internal/parser/languages.go | 53 ++++---- internal/parser/parser.go | 225 ++++++++++++++++----------------- internal/parser/pool.go | 2 +- 6 files changed, 294 insertions(+), 293 deletions(-) diff --git a/go.mod b/go.mod index d34ddca..32e7bad 100644 --- a/go.mod +++ b/go.mod @@ -1,51 +1,51 @@ module github.com/thuongh2/git-mimir -go 1.24.1 +go 1.25.0 require ( - github.com/go-git/go-git/v5 v5.11.0 + github.com/go-git/go-git/v5 v5.17.0 github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 - github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 - github.com/spf13/cobra v1.8.1 - modernc.org/sqlite v1.29.0 + github.com/spf13/cobra v1.10.2 + github.com/tree-sitter/go-tree-sitter v0.25.0 + github.com/tree-sitter/tree-sitter-cpp v0.23.4 + github.com/tree-sitter/tree-sitter-go v0.25.0 + github.com/tree-sitter/tree-sitter-java v0.23.5 + github.com/tree-sitter/tree-sitter-javascript v0.25.0 + github.com/tree-sitter/tree-sitter-python v0.25.0 + github.com/tree-sitter/tree-sitter-rust v0.24.0 + github.com/tree-sitter/tree-sitter-typescript v0.23.2 + modernc.org/sqlite v1.47.0 ) require ( dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect - github.com/cloudflare/circl v1.3.3 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/ProtonMail/go-crypto v1.1.6 // indirect + github.com/cloudflare/circl v1.6.1 // indirect + github.com/cyphar/filepath-securejoin v0.4.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/go-git/go-billy/v5 v5.8.0 // indirect + github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect - github.com/ncruces/go-strftime v0.1.9 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-pointer v0.0.1 // indirect + github.com/ncruces/go-strftime v1.0.0 // indirect + github.com/pjbgf/sha1cd v0.3.2 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/sergi/go-diff v1.1.0 // indirect - github.com/skeema/knownhosts v1.2.1 // indirect - github.com/spf13/pflag v1.0.5 // indirect + github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect + github.com/skeema/knownhosts v1.3.1 // indirect + github.com/spf13/pflag v1.0.9 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.41.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/crypto v0.45.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sys v0.42.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect - modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect - modernc.org/libc v1.41.0 // indirect - modernc.org/mathutil v1.6.0 // indirect - modernc.org/memory v1.7.2 // indirect - modernc.org/strutil v1.2.0 // indirect - modernc.org/token v1.1.0 // indirect + modernc.org/libc v1.70.0 // indirect + modernc.org/mathutil v1.7.1 // indirect + modernc.org/memory v1.11.0 // indirect ) diff --git a/go.sum b/go.sum index b2db78c..8057b1c 100644 --- a/go.sum +++ b/go.sum @@ -1,46 +1,44 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw= +github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0= +github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= +github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o= +github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= -github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= +github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= +github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-billy/v5 v5.8.0 h1:I8hjc3LbBlXTtVuFNJuwYuMiHvQJDq1AT6u4DwDzZG0= +github.com/go-git/go-billy/v5 v5.8.0/go.mod h1:RpvI/rw4Vr5QA+Z60c6d6LXH0rYJo0uD5SqfmrrheCY= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= -github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= -github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= +github.com/go-git/go-git/v5 v5.17.0 h1:AbyI4xf+7DsjINHMu35quAh4wJygKBKBuXVjV/pxesM= +github.com/go-git/go-git/v5 v5.17.0/go.mod h1:f82C4YiLx+Lhi8eHxltLeGC5uBTXSFa6PC5WW9o4SjI= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= +github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= @@ -58,112 +56,103 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= -github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= +github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= +github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= +github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= +github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= +github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4= +github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= -github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= -github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4= -github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= +github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tree-sitter/go-tree-sitter v0.25.0 h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU= +github.com/tree-sitter/go-tree-sitter v0.25.0/go.mod h1:r77ig7BikoZhHrrsjAnv8RqGti5rtSyvDHPzgTPsUuU= +github.com/tree-sitter/tree-sitter-c v0.23.4 h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c= +github.com/tree-sitter/tree-sitter-c v0.23.4/go.mod h1:MkI5dOiIpeN94LNjeCp8ljXN/953JCwAby4bClMr6bw= +github.com/tree-sitter/tree-sitter-cpp v0.23.4 h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w= +github.com/tree-sitter/tree-sitter-cpp v0.23.4/go.mod h1:doqNW64BriC7WBCQ1klf0KmJpdEvfxyXtoEybnBo6v8= +github.com/tree-sitter/tree-sitter-embedded-template v0.23.2 h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg= +github.com/tree-sitter/tree-sitter-embedded-template v0.23.2/go.mod h1:HNPOhN0qF3hWluYLdxWs5WbzP/iE4aaRVPMsdxuzIaQ= +github.com/tree-sitter/tree-sitter-go v0.25.0 h1:cEB0Q3LHgZtS+ECHx9wcP7AwzoOddJFQCVmytX42cVU= +github.com/tree-sitter/tree-sitter-go v0.25.0/go.mod h1:Jrx8QqYN0v7npv1fJRH1AznddllYiCMUChtVjxPK040= +github.com/tree-sitter/tree-sitter-html v0.23.2 h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc= +github.com/tree-sitter/tree-sitter-html v0.23.2/go.mod h1:gpUv/dG3Xl/eebqgeYeFMt+JLOY9cgFinb/Nw08a9og= +github.com/tree-sitter/tree-sitter-java v0.23.5 h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig= +github.com/tree-sitter/tree-sitter-java v0.23.5/go.mod h1:NRKlI8+EznxA7t1Yt3xtraPk1Wzqh3GAIC46wxvc320= +github.com/tree-sitter/tree-sitter-javascript v0.25.0 h1:ZkWETb66/w8cc13yhfnNuHOLDQWl3BnKlH6f9AdR88c= +github.com/tree-sitter/tree-sitter-javascript v0.25.0/go.mod h1:lmGD1EJdCA+v0S1u2fFgepMg/opzSg/4pgFym2FPGAs= +github.com/tree-sitter/tree-sitter-json v0.24.8 h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ= +github.com/tree-sitter/tree-sitter-json v0.24.8/go.mod h1:F351KK0KGvCaYbZ5zxwx/gWWvZhIDl0eMtn+1r+gQbo= +github.com/tree-sitter/tree-sitter-php v0.23.11 h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8= +github.com/tree-sitter/tree-sitter-php v0.23.11/go.mod h1:T/kbfi+UcCywQfUNAJnGTN/fMSUjnwPXA8k4yoIks74= +github.com/tree-sitter/tree-sitter-python v0.25.0 h1:O6XD9v8U1LOcRc3cNj9nM7XufrtEBezE6VrpRrHZDf0= +github.com/tree-sitter/tree-sitter-python v0.25.0/go.mod h1:cpdthSy/Yoa28aJFBscFHlGiU+cnSiSh1kuDVtI8YeM= +github.com/tree-sitter/tree-sitter-ruby v0.23.1 h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo= +github.com/tree-sitter/tree-sitter-ruby v0.23.1/go.mod h1:kUS4kCCQloFcdX6sdpr8p6r2rogbM6ZjTox5ZOQy8cA= +github.com/tree-sitter/tree-sitter-rust v0.24.0 h1:nr3ga5ThXyPR5n/DiMq4Zh3e8pMR+sfzk088QE809+g= +github.com/tree-sitter/tree-sitter-rust v0.24.0/go.mod h1:hfeGWic9BAfgTrc7Xf6FaOAguCFJRo3RBbs7QJ6D7MI= +github.com/tree-sitter/tree-sitter-typescript v0.23.2 h1:/Odvphn18PniVixb9e97X0DbNVsU6Qocv9mfkyzdXwU= +github.com/tree-sitter/tree-sitter-typescript v0.23.2/go.mod h1:zjzMXT/Ulffel2xfOcAkQQkiAkmgnbtPGlFQw/5X4xA= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= +golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= +golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY= +golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70= +golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8= +golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= -golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= +golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k= +golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -171,21 +160,35 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= -modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= -modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk= -modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY= -modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= -modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= -modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= -modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= -modernc.org/sqlite v1.29.0 h1:lQVw+ZsFM3aRG5m4myG70tbXpr3S/J1ej0KHIP4EvjM= -modernc.org/sqlite v1.29.0/go.mod h1:hG41jCYxOAOoO6BRK66AdRlmOcDzXf7qnwlwjUIOqa0= -modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= -modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= +modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis= +modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= +modernc.org/ccgo/v4 v4.32.0 h1:hjG66bI/kqIPX1b2yT6fr/jt+QedtP2fqojG2VrFuVw= +modernc.org/ccgo/v4 v4.32.0/go.mod h1:6F08EBCx5uQc38kMGl+0Nm0oWczoo1c7cgpzEry7Uc0= +modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM= +modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU= +modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= +modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/gc/v3 v3.1.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo= +modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY= +modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= +modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= +modernc.org/libc v1.70.0 h1:U58NawXqXbgpZ/dcdS9kMshu08aiA6b7gusEusqzNkw= +modernc.org/libc v1.70.0/go.mod h1:OVmxFGP1CI/Z4L3E0Q3Mf1PDE0BucwMkcXjjLntvHJo= +modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= +modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= +modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= +modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= +modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= +modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= +modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= +modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= +modernc.org/sqlite v1.47.0 h1:R1XyaNpoW4Et9yly+I2EeX7pBza/w+pmYee/0HJDyKk= +modernc.org/sqlite v1.47.0/go.mod h1:hWjRO6Tj/5Ik8ieqxQybiEOUXy0NJFNp2tpvVpKlvig= +modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= +modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/internal/graph/types.go b/internal/graph/types.go index 0949be0..c687917 100644 --- a/internal/graph/types.go +++ b/internal/graph/types.go @@ -20,8 +20,8 @@ type Node struct { Name string Kind string // Function|Method|Class|Interface|Variable|Constant|Type FilePath string - StartLine int - EndLine int + StartLine uint + EndLine uint Exported bool PackagePath string ClusterID string @@ -68,5 +68,5 @@ type ImportRef struct { type CallRef struct { FromUID string // node UID of the calling symbol CalleeName string // name of the callee as written in source - Line int + Line uint } diff --git a/internal/parser/languages.go b/internal/parser/languages.go index 3cb9f50..cd2ead0 100644 --- a/internal/parser/languages.go +++ b/internal/parser/languages.go @@ -1,15 +1,14 @@ package parser import ( - sitter "github.com/smacker/go-tree-sitter" - "github.com/smacker/go-tree-sitter/cpp" - "github.com/smacker/go-tree-sitter/golang" - "github.com/smacker/go-tree-sitter/java" - "github.com/smacker/go-tree-sitter/javascript" - "github.com/smacker/go-tree-sitter/python" - "github.com/smacker/go-tree-sitter/rust" - "github.com/smacker/go-tree-sitter/typescript/tsx" - "github.com/smacker/go-tree-sitter/typescript/typescript" + sitter "github.com/tree-sitter/go-tree-sitter" + cpp "github.com/tree-sitter/tree-sitter-cpp/bindings/go" + golang "github.com/tree-sitter/tree-sitter-go/bindings/go" + java "github.com/tree-sitter/tree-sitter-java/bindings/go" + javascript "github.com/tree-sitter/tree-sitter-javascript/bindings/go" + python "github.com/tree-sitter/tree-sitter-python/bindings/go" + rust "github.com/tree-sitter/tree-sitter-rust/bindings/go" + typescript "github.com/tree-sitter/tree-sitter-typescript/bindings/go" ) // LangID identifies a supported language. @@ -28,17 +27,17 @@ const ( // extToLang maps file extensions to language IDs. var extToLang = map[string]LangID{ - ".ts": LangTypeScript, - ".tsx": LangTSX, - ".js": LangJavaScript, - ".jsx": LangJavaScript, - ".go": LangGo, - ".py": LangPython, + ".ts": LangTypeScript, + ".tsx": LangTSX, + ".js": LangJavaScript, + ".jsx": LangJavaScript, + ".go": LangGo, + ".py": LangPython, ".java": LangJava, - ".rs": LangRust, - ".cpp": LangCPP, - ".cc": LangCPP, - ".cxx": LangCPP, + ".rs": LangRust, + ".cpp": LangCPP, + ".cc": LangCPP, + ".cxx": LangCPP, } // LangForExt returns the language ID for a file extension, or "" if unsupported. @@ -50,21 +49,21 @@ func LangForExt(ext string) LangID { func grammarForLang(id LangID) *sitter.Language { switch id { case LangTypeScript: - return typescript.GetLanguage() + return sitter.NewLanguage(typescript.LanguageTypescript()) case LangTSX: - return tsx.GetLanguage() + return sitter.NewLanguage(typescript.LanguageTSX()) case LangJavaScript: - return javascript.GetLanguage() + return sitter.NewLanguage(javascript.Language()) case LangGo: - return golang.GetLanguage() + return sitter.NewLanguage(golang.Language()) case LangPython: - return python.GetLanguage() + return sitter.NewLanguage(python.Language()) case LangJava: - return java.GetLanguage() + return sitter.NewLanguage(java.Language()) case LangRust: - return rust.GetLanguage() + return sitter.NewLanguage(rust.Language()) case LangCPP: - return cpp.GetLanguage() + return sitter.NewLanguage(cpp.Language()) default: return nil } diff --git a/internal/parser/parser.go b/internal/parser/parser.go index bf4d4cc..61394c0 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -7,8 +7,8 @@ import ( "path/filepath" "strings" - sitter "github.com/smacker/go-tree-sitter" "github.com/thuongh2/git-mimir/internal/graph" + sitter "github.com/tree-sitter/go-tree-sitter" ) // treeParser wraps a pre-allocated tree-sitter parser for one language. @@ -51,9 +51,9 @@ func ParseFile(path string, src []byte) (*graph.FileSymbols, error) { // parse extracts symbols from a source file using the pre-allocated parser. func (tp *treeParser) parse(path string, src []byte) (*graph.FileSymbols, error) { - tree, err := tp.parser.ParseCtx(context.Background(), nil, src) - if err != nil { - return nil, fmt.Errorf("parse %s: %w", path, err) + tree := tp.parser.ParseCtx(context.Background(), src, nil) + if tree == nil { + return nil, fmt.Errorf("parse %s failed", path) } defer tree.Close() @@ -85,18 +85,18 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols var walk func(n *sitter.Node, exported bool) walk = func(n *sitter.Node, exported bool) { - switch n.Type() { + switch n.Kind() { case "export_statement": // Mark children as exported - for i := 0; i < int(n.ChildCount()); i++ { + for i := uint(0); i < n.ChildCount(); i++ { child := n.Child(i) - if child.Type() != "export" && child.Type() != "default" { + if child.Kind() != "export" && child.Kind() != "default" { walk(child, true) } } // Handle re-exports: export { x } from './y' if source := n.ChildByFieldName("source"); source != nil { - importPath := strings.Trim(source.Content(src), `"'`) + importPath := strings.Trim(source.Utf8Text(src), `"'`) fs.Imports = append(fs.Imports, graph.ImportRef{ ImportPath: importPath, }) @@ -105,10 +105,10 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols case "import_statement": if source := n.ChildByFieldName("source"); source != nil { - importPath := strings.Trim(source.Content(src), `"'`) + importPath := strings.Trim(source.Utf8Text(src), `"'`) isType := false if importKind := n.ChildByFieldName("import"); importKind != nil { - isType = strings.Contains(importKind.Content(src), "type") + isType = strings.Contains(importKind.Utf8Text(src), "type") } fs.Imports = append(fs.Imports, graph.ImportRef{ ImportPath: importPath, @@ -119,15 +119,15 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols case "function_declaration": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Function") node := graph.Node{ UID: uid, Name: name, Kind: "Function", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: exported, } fs.Nodes = append(fs.Nodes, node) @@ -140,7 +140,7 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols case "method_definition": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) kind := "Method" uid := graph.NodeUID(path, currentClass+"."+name, kind) node := graph.Node{ @@ -148,8 +148,8 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols Name: name, Kind: kind, FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: exported || currentClass != "", } fs.Nodes = append(fs.Nodes, node) @@ -168,15 +168,15 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols case "class_declaration": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Class") node := graph.Node{ UID: uid, Name: name, Kind: "Class", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: exported, } fs.Nodes = append(fs.Nodes, node) @@ -196,15 +196,15 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols case "interface_declaration": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Interface") fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: "Interface", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: exported, }) } @@ -212,22 +212,22 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols case "lexical_declaration", "variable_declaration": // Handle: const foo = () => {} or const foo = function() {} for i := 0; i < int(n.ChildCount()); i++ { - child := n.Child(i) - if child.Type() == "variable_declarator" { + child := n.Child(uint(i)) + if child.Kind() == "variable_declarator" { nameNode := child.ChildByFieldName("name") valNode := child.ChildByFieldName("value") if nameNode != nil && valNode != nil { kind := kindOfVarDecl(valNode) if kind != "" { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, kind) fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: kind, FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: exported, }) extractCalls(valNode, src, uid, fs) @@ -239,7 +239,7 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols // Recurse for i := 0; i < int(n.ChildCount()); i++ { - walk(n.Child(i), false) + walk(n.Child(uint(i)), false) } } @@ -247,7 +247,7 @@ func extractTS(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols } func kindOfVarDecl(n *sitter.Node) string { - switch n.Type() { + switch n.Kind() { case "arrow_function", "function", "function_expression": return "Function" case "class": @@ -259,25 +259,25 @@ func kindOfVarDecl(n *sitter.Node) string { func extractHeritage(n *sitter.Node, src []byte, ownerUID string, fs *graph.FileSymbols) { for i := 0; i < int(n.ChildCount()); i++ { - child := n.Child(i) - switch child.Type() { + child := n.Child(uint(i)) + switch child.Kind() { case "extends_clause": for j := 0; j < int(child.ChildCount()); j++ { - c := child.Child(j) - if c.Type() == "identifier" || c.Type() == "type_identifier" { + c := child.Child(uint(j)) + if c.Kind() == "identifier" || c.Kind() == "type_identifier" { fs.Calls = append(fs.Calls, graph.CallRef{ FromUID: ownerUID, - CalleeName: "EXTENDS:" + c.Content(src), + CalleeName: "EXTENDS:" + c.Utf8Text(src), }) } } case "implements_clause": for j := 0; j < int(child.ChildCount()); j++ { - c := child.Child(j) - if c.Type() == "type_identifier" || c.Type() == "identifier" { + c := child.Child(uint(j)) + if c.Kind() == "type_identifier" || c.Kind() == "identifier" { fs.Calls = append(fs.Calls, graph.CallRef{ FromUID: ownerUID, - CalleeName: "IMPLEMENTS:" + c.Content(src), + CalleeName: "IMPLEMENTS:" + c.Utf8Text(src), }) } } @@ -288,7 +288,7 @@ func extractHeritage(n *sitter.Node, src []byte, ownerUID string, fs *graph.File func extractCalls(n *sitter.Node, src []byte, ownerUID string, fs *graph.FileSymbols) { var walk func(n *sitter.Node) walk = func(n *sitter.Node) { - if n.Type() == "call_expression" { + if n.Kind() == "call_expression" { fn := n.ChildByFieldName("function") if fn != nil { callee := calleeText(fn, src) @@ -296,27 +296,27 @@ func extractCalls(n *sitter.Node, src []byte, ownerUID string, fs *graph.FileSym fs.Calls = append(fs.Calls, graph.CallRef{ FromUID: ownerUID, CalleeName: callee, - Line: int(n.StartPoint().Row) + 1, + Line: n.StartPosition().Row + 1, }) } } } for i := 0; i < int(n.ChildCount()); i++ { - walk(n.Child(i)) + walk(n.Child(uint(i))) } } walk(n) } func calleeText(n *sitter.Node, src []byte) string { - switch n.Type() { + switch n.Kind() { case "identifier": - return n.Content(src) + return n.Utf8Text(src) case "member_expression": obj := n.ChildByFieldName("object") prop := n.ChildByFieldName("property") if obj != nil && prop != nil { - return obj.Content(src) + "." + prop.Content(src) + return obj.Utf8Text(src) + "." + prop.Utf8Text(src) } } return "" @@ -330,15 +330,15 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols var walk func(n *sitter.Node) walk = func(n *sitter.Node) { - switch n.Type() { + switch n.Kind() { case "import_declaration", "import_spec": - if n.Type() == "import_spec" { + if n.Kind() == "import_spec" { pathNode := n.ChildByFieldName("path") if pathNode != nil { - importPath := strings.Trim(pathNode.Content(src), `"`) + importPath := strings.Trim(pathNode.Utf8Text(src), `"`) alias := "" if nameNode := n.ChildByFieldName("name"); nameNode != nil { - alias = nameNode.Content(src) + alias = nameNode.Utf8Text(src) } fs.Imports = append(fs.Imports, graph.ImportRef{ ImportPath: importPath, @@ -350,7 +350,7 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols case "function_declaration": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) exported := len(name) > 0 && name[0] >= 'A' && name[0] <= 'Z' uid := graph.NodeUID(path, name, "Function") fs.Nodes = append(fs.Nodes, graph.Node{ @@ -358,8 +358,8 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols Name: name, Kind: "Function", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: exported, PackagePath: pkgPath, }) @@ -374,10 +374,10 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols nameNode := n.ChildByFieldName("name") receiverNode := n.ChildByFieldName("receiver") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) receiverType := "" if receiverNode != nil { - receiverType = receiverNode.Content(src) + receiverType = receiverNode.Utf8Text(src) // Strip parens and type parts: "(r *Foo)" -> "Foo" receiverType = strings.Trim(receiverType, "()") parts := strings.Fields(receiverType) @@ -393,8 +393,8 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols Name: name, Kind: "Method", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: exported, PackagePath: pkgPath, }) @@ -407,17 +407,17 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols case "type_declaration": for i := 0; i < int(n.ChildCount()); i++ { - spec := n.Child(i) - if spec.Type() == "type_spec" { + spec := n.Child(uint(i)) + if spec.Kind() == "type_spec" { nameNode := spec.ChildByFieldName("name") typeNode := spec.ChildByFieldName("type") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) exported := len(name) > 0 && name[0] >= 'A' && name[0] <= 'Z' kind := "Type" - if typeNode != nil && typeNode.Type() == "struct_type" { + if typeNode != nil && typeNode.Kind() == "struct_type" { kind = "Class" - } else if typeNode != nil && typeNode.Type() == "interface_type" { + } else if typeNode != nil && typeNode.Kind() == "interface_type" { kind = "Interface" } uid := graph.NodeUID(path, name, kind) @@ -426,8 +426,8 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols Name: name, Kind: kind, FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: exported, PackagePath: pkgPath, }) @@ -437,7 +437,7 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols } for i := 0; i < int(n.ChildCount()); i++ { - walk(n.Child(i)) + walk(n.Child(uint(i))) } } walk(root) @@ -448,13 +448,13 @@ func extractGo(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols func extractPython(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols) { var walk func(n *sitter.Node) walk = func(n *sitter.Node) { - switch n.Type() { + switch n.Kind() { case "import_statement", "import_from_statement": - if n.Type() == "import_from_statement" { + if n.Kind() == "import_from_statement" { modNode := n.ChildByFieldName("module_name") if modNode != nil { fs.Imports = append(fs.Imports, graph.ImportRef{ - ImportPath: modNode.Content(src), + ImportPath: modNode.Utf8Text(src), }) } } @@ -462,15 +462,15 @@ func extractPython(root *sitter.Node, src []byte, path string, fs *graph.FileSym case "function_definition": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Function") fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: "Function", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: !strings.HasPrefix(name, "_"), }) if body := n.ChildByFieldName("body"); body != nil { @@ -482,21 +482,21 @@ func extractPython(root *sitter.Node, src []byte, path string, fs *graph.FileSym case "class_definition": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Class") fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: "Class", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: !strings.HasPrefix(name, "_"), }) } } for i := 0; i < int(n.ChildCount()); i++ { - walk(n.Child(i)) + walk(n.Child(uint(i))) } } walk(root) @@ -505,21 +505,21 @@ func extractPython(root *sitter.Node, src []byte, path string, fs *graph.FileSym func extractCallsPython(n *sitter.Node, src []byte, ownerUID string, fs *graph.FileSymbols) { var walk func(n *sitter.Node) walk = func(n *sitter.Node) { - if n.Type() == "call" { + if n.Kind() == "call" { fn := n.ChildByFieldName("function") if fn != nil { - callee := fn.Content(src) + callee := fn.Utf8Text(src) if callee != "" { fs.Calls = append(fs.Calls, graph.CallRef{ FromUID: ownerUID, CalleeName: callee, - Line: int(n.StartPoint().Row) + 1, + Line: n.StartPosition().Row + 1, }) } } } for i := 0; i < int(n.ChildCount()); i++ { - walk(n.Child(i)) + walk(n.Child(uint(i))) } } walk(n) @@ -530,45 +530,45 @@ func extractCallsPython(n *sitter.Node, src []byte, ownerUID string, fs *graph.F func extractJava(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols) { var walk func(n *sitter.Node) walk = func(n *sitter.Node) { - switch n.Type() { + switch n.Kind() { case "import_declaration": for i := 0; i < int(n.ChildCount()); i++ { - c := n.Child(i) - if c.Type() == "scoped_identifier" { - fs.Imports = append(fs.Imports, graph.ImportRef{ImportPath: c.Content(src)}) + c := n.Child(uint(i)) + if c.Kind() == "scoped_identifier" { + fs.Imports = append(fs.Imports, graph.ImportRef{ImportPath: c.Utf8Text(src)}) } } case "class_declaration", "interface_declaration", "enum_declaration": nameNode := n.ChildByFieldName("name") if nameNode != nil { kind := "Class" - if n.Type() == "interface_declaration" { + if n.Kind() == "interface_declaration" { kind = "Interface" } - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, kind) fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: kind, FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: true, }) } case "method_declaration": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Method") fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: "Method", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: true, }) if body := n.ChildByFieldName("body"); body != nil { @@ -578,7 +578,7 @@ func extractJava(root *sitter.Node, src []byte, path string, fs *graph.FileSymbo } } for i := 0; i < int(n.ChildCount()); i++ { - walk(n.Child(i)) + walk(n.Child(uint(i))) } } walk(root) @@ -589,21 +589,21 @@ func extractJava(root *sitter.Node, src []byte, path string, fs *graph.FileSymbo func extractRust(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols) { var walk func(n *sitter.Node) walk = func(n *sitter.Node) { - switch n.Type() { + switch n.Kind() { case "use_declaration": for i := 0; i < int(n.ChildCount()); i++ { - c := n.Child(i) - if c.Type() == "scoped_identifier" || c.Type() == "identifier" { - fs.Imports = append(fs.Imports, graph.ImportRef{ImportPath: c.Content(src)}) + c := n.Child(uint(i)) + if c.Kind() == "scoped_identifier" || c.Kind() == "identifier" { + fs.Imports = append(fs.Imports, graph.ImportRef{ImportPath: c.Utf8Text(src)}) } } case "function_item": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Function") pub := false - if n.Child(0) != nil && n.Child(0).Content(src) == "pub" { + if n.Child(0) != nil && n.Child(0).Utf8Text(src) == "pub" { pub = true } fs.Nodes = append(fs.Nodes, graph.Node{ @@ -611,8 +611,8 @@ func extractRust(root *sitter.Node, src []byte, path string, fs *graph.FileSymbo Name: name, Kind: "Function", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, Exported: pub, }) if body := n.ChildByFieldName("body"); body != nil { @@ -624,23 +624,23 @@ func extractRust(root *sitter.Node, src []byte, path string, fs *graph.FileSymbo nameNode := n.ChildByFieldName("name") if nameNode != nil { kind := "Class" - if n.Type() == "trait_item" { + if n.Kind() == "trait_item" { kind = "Interface" } - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, kind) fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: kind, FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, }) } } for i := 0; i < int(n.ChildCount()); i++ { - walk(n.Child(i)) + walk(n.Child(uint(i))) } } walk(root) @@ -651,26 +651,26 @@ func extractRust(root *sitter.Node, src []byte, path string, fs *graph.FileSymbo func extractCPP(root *sitter.Node, src []byte, path string, fs *graph.FileSymbols) { var walk func(n *sitter.Node) walk = func(n *sitter.Node) { - switch n.Type() { + switch n.Kind() { case "preproc_include": pathNode := n.ChildByFieldName("path") if pathNode != nil { - fs.Imports = append(fs.Imports, graph.ImportRef{ImportPath: pathNode.Content(src)}) + fs.Imports = append(fs.Imports, graph.ImportRef{ImportPath: pathNode.Utf8Text(src)}) } case "function_definition": declarator := n.ChildByFieldName("declarator") if declarator != nil { nameNode := findFirstIdentifier(declarator) if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Function") fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: "Function", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, }) if body := n.ChildByFieldName("body"); body != nil { extractCalls(body, src, uid, fs) @@ -681,34 +681,33 @@ func extractCPP(root *sitter.Node, src []byte, path string, fs *graph.FileSymbol case "class_specifier", "struct_specifier": nameNode := n.ChildByFieldName("name") if nameNode != nil { - name := nameNode.Content(src) + name := nameNode.Utf8Text(src) uid := graph.NodeUID(path, name, "Class") fs.Nodes = append(fs.Nodes, graph.Node{ UID: uid, Name: name, Kind: "Class", FilePath: path, - StartLine: int(n.StartPoint().Row) + 1, - EndLine: int(n.EndPoint().Row) + 1, + StartLine: n.StartPosition().Row + 1, + EndLine: n.EndPosition().Row + 1, }) } } for i := 0; i < int(n.ChildCount()); i++ { - walk(n.Child(i)) + walk(n.Child(uint(i))) } } walk(root) } func findFirstIdentifier(n *sitter.Node) *sitter.Node { - if n.Type() == "identifier" || n.Type() == "qualified_identifier" { + if n.Kind() == "identifier" || n.Kind() == "qualified_identifier" { return n } for i := 0; i < int(n.ChildCount()); i++ { - if found := findFirstIdentifier(n.Child(i)); found != nil { + if found := findFirstIdentifier(n.Child(uint(i))); found != nil { return found } } return nil } - diff --git a/internal/parser/pool.go b/internal/parser/pool.go index 515806d..47fe17d 100644 --- a/internal/parser/pool.go +++ b/internal/parser/pool.go @@ -9,9 +9,9 @@ import ( "runtime" "sync" - sitter "github.com/smacker/go-tree-sitter" "github.com/thuongh2/git-mimir/internal/graph" "github.com/thuongh2/git-mimir/internal/walker" + sitter "github.com/tree-sitter/go-tree-sitter" ) // worker holds a pre-allocated set of parsers (one per supported language)