@surething/cockpit 1.0.210 → 1.0.212
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next-prod/BUILD_ID +1 -1
- package/.next-prod/app-path-routes-manifest.json +9 -5
- package/.next-prod/build-manifest.json +2 -2
- package/.next-prod/prerender-manifest.json +3 -3
- package/.next-prod/routes-manifest.json +24 -0
- package/.next-prod/server/app/_global-error/page.js +3 -3
- package/.next-prod/server/app/_global-error/page.js.nft.json +1 -1
- package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_global-error.html +1 -1
- package/.next-prod/server/app/_global-error.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found/page.js +2 -2
- package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
- package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_not-found.html +1 -1
- package/.next-prod/server/app/_not-found.rsc +4 -4
- package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next-prod/server/app/api/agent/test/route.js +1 -1
- package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/bash/route.js +1 -1
- package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/codex/route.js +78 -4
- package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/deepseek/route.js +78 -4
- package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/kimi/route.js +87 -13
- package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/ollama/route.js +89 -15
- package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/route.js +78 -4
- package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/claude-stats/route.js +1 -1
- package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/commands/route.js +1 -1
- package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/comments/route.js +1 -1
- package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/columns/route.js +2 -2
- package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/connect/route.js +1 -1
- package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/export/route.js +1 -1
- package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/query/route.js +1 -1
- package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/schemas/route.js +1 -1
- package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/dev/spans/route.js +1 -1
- package/.next-prod/server/app/api/dev/spans/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/extension/version/route.js +1 -1
- package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/file/route.js +1 -1
- package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/blame/route.js +1 -1
- package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
- package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/copy/route.js +1 -1
- package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/delete/route.js +1 -1
- package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/expanded/route.js +1 -1
- package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/index/route.js +1 -1
- package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/init/route.js +1 -1
- package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/paste/route.js +1 -1
- package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/read/route.js +1 -1
- package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/readdir/route.js +1 -1
- package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/recent/route.js +1 -1
- package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/save/route.js +1 -1
- package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/search/route.js +1 -1
- package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/stat/route.js +1 -1
- package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/text/route.js +1 -1
- package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
- package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/branches/route.js +1 -1
- package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
- package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/commits/route.js +1 -1
- package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/diff/route.js +1 -1
- package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/discard/route.js +1 -1
- package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/stage/route.js +1 -1
- package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/status/route.js +1 -1
- package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/unstage/route.js +1 -1
- package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/worktree/route.js +1 -1
- package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/global-state/route.js +1 -1
- package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/jupyter/load/route.js +1 -1
- package/.next-prod/server/app/api/jupyter/load/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/jupyter/save/route.js +1 -1
- package/.next-prod/server/app/api/jupyter/save/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/jupyter/shutdown/route.js +1 -1
- package/.next-prod/server/app/api/jupyter/shutdown/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
- package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
- package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/references/route.js +1 -1
- package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/status/route.js +1 -1
- package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
- package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/columns/route.js +1 -1
- package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
- package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/export/route.js +1 -1
- package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/query/route.js +1 -1
- package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/schemas/route.js +1 -1
- package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/note/route.js +1 -1
- package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/models/route.js +1 -1
- package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/start/route.js +1 -1
- package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/open-cursor/route.js +1 -1
- package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/open-vscode/route.js +1 -1
- package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/pick-folder/route.js +1 -1
- package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
- package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/project-settings/route.js +1 -1
- package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/project-state/route.js +1 -1
- package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/callees/route.js +1 -0
- package/.next-prod/server/app/api/projectGraph/callees/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/projectGraph/callees/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/projectGraph/callers/route.js +1 -0
- package/.next-prod/server/app/api/projectGraph/callers/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/projectGraph/callers/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/projectGraph/coedit/route.js +1 -0
- package/.next-prod/server/app/api/projectGraph/coedit/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/projectGraph/coedit/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/projectGraph/file/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/file-functions/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/impact/route.js +1 -0
- package/.next-prod/server/app/api/projectGraph/impact/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/projectGraph/impact/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projects/route.js +1 -1
- package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/command/route.js +1 -1
- package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/connect/route.js +1 -1
- package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/delete/route.js +1 -1
- package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/get/route.js +1 -1
- package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/keys/route.js +1 -1
- package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/set/route.js +1 -1
- package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -1
- package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -1
- package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/[id]/route.js +1 -1
- package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/identify/route.js +1 -1
- package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/order/route.js +1 -1
- package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/route.js +1 -1
- package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/share-info/route.js +1 -1
- package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/users/route.js +1 -1
- package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/scheduled-tasks/route.js +1 -1
- package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/services/config/route.js +1 -1
- package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/services/scripts/route.js +1 -1
- package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session-by-path/route.js +1 -1
- package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/route.js +1 -1
- package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/settings/route.js +1 -1
- package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
- package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/content/route.js +1 -1
- package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/route.js +1 -1
- package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
- package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
- package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
- package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/env/route.js +1 -1
- package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/history/route.js +1 -1
- package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/version/route.js +1 -1
- package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
- package/.next-prod/server/app/favicon.ico/route.js +1 -1
- package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
- package/.next-prod/server/app/manifest.webmanifest/route.js +2 -2
- package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/.next-prod/server/app/manifest.webmanifest.body +1 -1
- package/.next-prod/server/app/page.js +2 -2
- package/.next-prod/server/app/page.js.nft.json +1 -1
- package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/project/page.js +2 -2
- package/.next-prod/server/app/project/page.js.nft.json +1 -1
- package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/review/[id]/page.js +2 -2
- package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
- package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app-paths-manifest.json +9 -5
- package/.next-prod/server/chunks/2939.js +1 -0
- package/.next-prod/server/chunks/5616.js +1 -1
- package/.next-prod/server/chunks/6955.js +1 -1
- package/.next-prod/server/chunks/8916.js +1 -1
- package/.next-prod/server/chunks/9658.js +2 -2
- package/.next-prod/server/middleware-build-manifest.js +1 -1
- package/.next-prod/server/pages/404.html +1 -1
- package/.next-prod/server/pages/500.html +1 -1
- package/.next-prod/server/server-reference-manifest.json +1 -1
- package/.next-prod/static/IVZ8ReZv3wH9JQhz4PDC2/_buildManifest.js +1 -0
- package/.next-prod/static/chunks/6345-3da1914a1a74c1fb.js +14 -0
- package/.next-prod/static/chunks/app/_global-error/page-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/agent/test/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/bash/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/codex/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/deepseek/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/kimi/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/ollama/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/claude-stats/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/commands/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/comments/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/db/columns/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/db/connect/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/db/disconnect/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/db/export/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/db/query/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/db/schemas/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/dev/spans/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/extension/version/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/file/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/blame/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/clipboard/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/copy/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/delete/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/expanded/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/index/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/init/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/paste/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/read/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/readdir/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/recent/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/save/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/search/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/stat/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/files/text/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/branch-diff/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/branches/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/commit-diff/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/commits/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/diff/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/discard/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/stage/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/status/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/unstage/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/git/worktree/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/global-state/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/jupyter/load/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/jupyter/save/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/definition/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/hover/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/references/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/status/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/warmup/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/columns/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/connect/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/disconnect/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/export/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/query/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/schemas/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/connect/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/query/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/schema/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/note/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/models/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/start/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/open-cursor/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/open-vscode/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/pick-folder/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/pinned-sessions/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/project-settings/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/project-state/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/callees/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/callers/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/file/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/impact/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/search/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/projects/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/command/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/connect/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/delete/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/disconnect/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/get/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/keys/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/set/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/comments/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/replies/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/review/identify/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/review/order/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/review/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/review/share-info/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/review/users/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/scheduled-tasks/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/services/config/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/services/scripts/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/session-by-path/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/projects/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/settings/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/[id]/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/content/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/aliases/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/env/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/history/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/api/version/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/app/manifest.webmanifest/route-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-994734ef0d317687.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-994734ef0d317687.js +1 -0
- package/.next-prod/static/css/f9a27209b85d8e5a.css +1 -0
- package/.next-prod/trace +12 -12
- package/.next-prod/trace-build +1 -1
- package/.next-prod/types/app/api/projectGraph/callees/route.ts +351 -0
- package/.next-prod/types/app/api/projectGraph/callers/route.ts +351 -0
- package/.next-prod/types/app/api/projectGraph/coedit/route.ts +351 -0
- package/.next-prod/types/app/api/projectGraph/impact/route.ts +351 -0
- package/.next-prod/types/routes.d.ts +5 -1
- package/.next-prod/types/validator.ts +36 -0
- package/README.md +16 -28
- package/README.zh.md +16 -28
- package/chrome-extension/manifest.json +2 -2
- package/dist/wsServer.mjs +2730 -4
- package/package.json +3 -3
- package/.next-prod/server/chunks/5159.js +0 -1
- package/.next-prod/static/LJRtmjYCuVrSA_dcelxlR/_buildManifest.js +0 -1
- package/.next-prod/static/chunks/6345-3c06cdc8c89677b8.js +0 -14
- package/.next-prod/static/chunks/app/_global-error/page-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/agent/test/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/bash/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/codex/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/deepseek/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/kimi/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/ollama/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/claude-stats/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/commands/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/comments/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/db/columns/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/db/connect/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/db/disconnect/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/db/export/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/db/query/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/db/schemas/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/dev/spans/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/extension/version/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/file/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/blame/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/clipboard/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/copy/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/delete/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/expanded/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/index/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/init/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/paste/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/read/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/readdir/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/recent/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/save/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/search/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/stat/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/files/text/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/branch-diff/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/branches/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/commit-diff/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/commits/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/diff/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/discard/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/stage/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/status/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/unstage/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/git/worktree/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/global-state/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/jupyter/load/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/jupyter/save/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/definition/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/hover/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/references/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/status/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/warmup/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/columns/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/connect/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/disconnect/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/export/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/query/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/schemas/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/connect/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/query/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/schema/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/note/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/models/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/start/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/open-cursor/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/open-vscode/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/pick-folder/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/pinned-sessions/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/project-settings/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/project-state/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/file/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/search/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/projects/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/command/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/connect/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/delete/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/disconnect/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/get/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/keys/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/set/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/review/[id]/comments/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/review/[id]/replies/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/review/[id]/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/review/identify/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/review/order/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/review/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/review/share-info/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/review/users/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/scheduled-tasks/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/services/config/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/services/scripts/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/session-by-path/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/projects/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/settings/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/[id]/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/content/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/aliases/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/env/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/history/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/api/version/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/app/manifest.webmanifest/route-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-826847d169541fa9.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-826847d169541fa9.js +0 -1
- package/.next-prod/static/css/dcde719317bea028.css +0 -1
- /package/.next-prod/static/{LJRtmjYCuVrSA_dcelxlR → IVZ8ReZv3wH9JQhz4PDC2}/_ssgManifest.js +0 -0
package/dist/wsServer.mjs
CHANGED
|
@@ -66,10 +66,10 @@ var fromWebSocket = (ws, proto) => Effect_exports.gen(function* () {
|
|
|
66
66
|
ws.on("error", onError);
|
|
67
67
|
return { onMessage, onClose, onError };
|
|
68
68
|
}),
|
|
69
|
-
(
|
|
70
|
-
ws.off("message",
|
|
71
|
-
ws.off("close",
|
|
72
|
-
ws.off("error",
|
|
69
|
+
(handlers2) => Effect_exports.sync(() => {
|
|
70
|
+
ws.off("message", handlers2.onMessage);
|
|
71
|
+
ws.off("close", handlers2.onClose);
|
|
72
|
+
ws.off("error", handlers2.onError);
|
|
73
73
|
})
|
|
74
74
|
);
|
|
75
75
|
const send = (msg) => Effect_exports.try({
|
|
@@ -1188,7 +1188,2733 @@ var runTerminalHandler = (ws, projectCwd) => {
|
|
|
1188
1188
|
});
|
|
1189
1189
|
};
|
|
1190
1190
|
|
|
1191
|
+
// packages/feature/explorer/src/server/codeMap/projectGraph/codeIndex.ts
|
|
1192
|
+
import { promises as fs4 } from "fs";
|
|
1193
|
+
import path6 from "path";
|
|
1194
|
+
|
|
1195
|
+
// packages/feature/explorer/src/server/codeMap/projectGraph/buildGraph.ts
|
|
1196
|
+
import { exec } from "child_process";
|
|
1197
|
+
import { promises as fs } from "fs";
|
|
1198
|
+
import path from "path";
|
|
1199
|
+
import { promisify } from "util";
|
|
1200
|
+
|
|
1201
|
+
// packages/feature/explorer/src/server/codeMap/handlers/registry.ts
|
|
1202
|
+
var handlers = /* @__PURE__ */ new Map();
|
|
1203
|
+
function registerHandler(handler) {
|
|
1204
|
+
handlers.set(handler.grammarId, handler);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
// packages/feature/explorer/src/server/codeMap/projectGraph/buildGraph.ts
|
|
1208
|
+
var execAsync = promisify(exec);
|
|
1209
|
+
var RESOLUTION_EXT = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
1210
|
+
var STRIPPABLE_EXT = [".js", ".jsx", ".mjs", ".cjs"];
|
|
1211
|
+
function findFileForBase(baseAbs, cwd, fileSet) {
|
|
1212
|
+
let baseRel = path.relative(cwd, baseAbs);
|
|
1213
|
+
if (baseRel.startsWith("..")) return null;
|
|
1214
|
+
for (const ext of STRIPPABLE_EXT) {
|
|
1215
|
+
if (baseRel.endsWith(ext)) {
|
|
1216
|
+
baseRel = baseRel.slice(0, -ext.length);
|
|
1217
|
+
break;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
if (fileSet.has(baseRel)) return baseRel;
|
|
1221
|
+
for (const ext of RESOLUTION_EXT) {
|
|
1222
|
+
const c = baseRel + ext;
|
|
1223
|
+
if (fileSet.has(c)) return c;
|
|
1224
|
+
}
|
|
1225
|
+
for (const ext of RESOLUTION_EXT) {
|
|
1226
|
+
const c = path.join(baseRel, "index" + ext);
|
|
1227
|
+
if (fileSet.has(c)) return c;
|
|
1228
|
+
}
|
|
1229
|
+
return null;
|
|
1230
|
+
}
|
|
1231
|
+
function fileInScope(file, scope) {
|
|
1232
|
+
return scope === "" || file === scope || file.startsWith(scope + "/");
|
|
1233
|
+
}
|
|
1234
|
+
async function loadWorkspaces(cwd, fileSet) {
|
|
1235
|
+
const patterns = await readWorkspacePatterns(cwd);
|
|
1236
|
+
if (patterns.length === 0) return /* @__PURE__ */ new Map();
|
|
1237
|
+
let pkgJsonPaths = [];
|
|
1238
|
+
try {
|
|
1239
|
+
const { stdout } = await execAsync(
|
|
1240
|
+
"git -c core.quotePath=false ls-files --cached --others --exclude-standard",
|
|
1241
|
+
{ cwd, maxBuffer: 50 * 1024 * 1024 }
|
|
1242
|
+
);
|
|
1243
|
+
pkgJsonPaths = stdout.split("\n").map((p) => p.trim()).filter((p) => p.endsWith("/package.json") && !p.includes("node_modules/"));
|
|
1244
|
+
} catch {
|
|
1245
|
+
return /* @__PURE__ */ new Map();
|
|
1246
|
+
}
|
|
1247
|
+
const matched = pkgJsonPaths.filter((p) => {
|
|
1248
|
+
const dir = p.slice(0, -"/package.json".length);
|
|
1249
|
+
return patterns.some((pat) => globMatchesDir(dir, pat));
|
|
1250
|
+
});
|
|
1251
|
+
const result = /* @__PURE__ */ new Map();
|
|
1252
|
+
for (const rel of matched) {
|
|
1253
|
+
let pkg;
|
|
1254
|
+
try {
|
|
1255
|
+
pkg = JSON.parse(await fs.readFile(path.join(cwd, rel), "utf8"));
|
|
1256
|
+
} catch {
|
|
1257
|
+
continue;
|
|
1258
|
+
}
|
|
1259
|
+
if (typeof pkg.name !== "string") continue;
|
|
1260
|
+
const dir = path.dirname(rel);
|
|
1261
|
+
const entryFile = resolveWorkspaceEntry(dir, pkg, fileSet);
|
|
1262
|
+
result.set(pkg.name, { name: pkg.name, dir, entryFile });
|
|
1263
|
+
}
|
|
1264
|
+
return result;
|
|
1265
|
+
}
|
|
1266
|
+
async function readWorkspacePatterns(cwd) {
|
|
1267
|
+
try {
|
|
1268
|
+
const yaml = await fs.readFile(path.join(cwd, "pnpm-workspace.yaml"), "utf8");
|
|
1269
|
+
return parsePnpmWorkspaces(yaml);
|
|
1270
|
+
} catch {
|
|
1271
|
+
}
|
|
1272
|
+
try {
|
|
1273
|
+
const pkg = JSON.parse(await fs.readFile(path.join(cwd, "package.json"), "utf8"));
|
|
1274
|
+
const ws = pkg?.workspaces;
|
|
1275
|
+
if (Array.isArray(ws)) return ws.filter((s) => typeof s === "string");
|
|
1276
|
+
if (ws && Array.isArray(ws.packages)) {
|
|
1277
|
+
return ws.packages.filter((s) => typeof s === "string");
|
|
1278
|
+
}
|
|
1279
|
+
} catch {
|
|
1280
|
+
}
|
|
1281
|
+
return [];
|
|
1282
|
+
}
|
|
1283
|
+
function parsePnpmWorkspaces(yaml) {
|
|
1284
|
+
const out = [];
|
|
1285
|
+
let inPackages = false;
|
|
1286
|
+
for (const rawLine of yaml.split("\n")) {
|
|
1287
|
+
const line = rawLine.replace(/#.*$/, "");
|
|
1288
|
+
if (/^packages\s*:/.test(line)) {
|
|
1289
|
+
inPackages = true;
|
|
1290
|
+
continue;
|
|
1291
|
+
}
|
|
1292
|
+
if (!inPackages) continue;
|
|
1293
|
+
const itemMatch = line.match(/^\s*-\s*['"]?([^'"#\s]+)['"]?\s*$/);
|
|
1294
|
+
if (itemMatch) {
|
|
1295
|
+
out.push(itemMatch[1]);
|
|
1296
|
+
} else if (/^\S/.test(line)) {
|
|
1297
|
+
inPackages = false;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
return out;
|
|
1301
|
+
}
|
|
1302
|
+
function globMatchesDir(dir, pattern) {
|
|
1303
|
+
const re = new RegExp(
|
|
1304
|
+
"^" + pattern.replace(/\\/g, "/").replace(/[.+^${}()|[\]]/g, "\\$&").replace(/\*\*/g, "___DOUBLESTAR___").replace(/\*/g, "[^/]*").replace(/___DOUBLESTAR___/g, ".*") + "$"
|
|
1305
|
+
);
|
|
1306
|
+
return re.test(dir);
|
|
1307
|
+
}
|
|
1308
|
+
function resolveWorkspaceEntry(pkgDir, pkg, fileSet) {
|
|
1309
|
+
const tryRelToPkg = (subpath) => {
|
|
1310
|
+
const cleaned = subpath.replace(/^\.\//, "");
|
|
1311
|
+
return findFileRelativeToProject(path.posix.join(pkgDir, cleaned), fileSet);
|
|
1312
|
+
};
|
|
1313
|
+
const exp = pkg.exports;
|
|
1314
|
+
let exportEntry;
|
|
1315
|
+
if (typeof exp === "string") {
|
|
1316
|
+
exportEntry = exp;
|
|
1317
|
+
} else if (exp && typeof exp === "object" && exp["."]) {
|
|
1318
|
+
const dot = exp["."];
|
|
1319
|
+
if (typeof dot === "string") exportEntry = dot;
|
|
1320
|
+
else if (dot && typeof dot === "object") {
|
|
1321
|
+
exportEntry = dot["types"] ?? dot["import"] ?? dot["default"] ?? dot["require"];
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
if (typeof exportEntry === "string") {
|
|
1325
|
+
const r = tryRelToPkg(exportEntry);
|
|
1326
|
+
if (r) return r;
|
|
1327
|
+
}
|
|
1328
|
+
if (typeof pkg.main === "string") {
|
|
1329
|
+
const r = tryRelToPkg(pkg.main);
|
|
1330
|
+
if (r) return r;
|
|
1331
|
+
}
|
|
1332
|
+
for (const conv of ["src/index.ts", "src/index.tsx", "index.ts", "index.tsx", "src/index.js", "index.js"]) {
|
|
1333
|
+
if (fileSet.has(path.posix.join(pkgDir, conv))) {
|
|
1334
|
+
return path.posix.join(pkgDir, conv);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
return null;
|
|
1338
|
+
}
|
|
1339
|
+
function findFileRelativeToProject(baseRel, fileSet) {
|
|
1340
|
+
if (baseRel.startsWith("..") || baseRel.startsWith("/")) return null;
|
|
1341
|
+
for (const ext of STRIPPABLE_EXT) {
|
|
1342
|
+
if (baseRel.endsWith(ext)) {
|
|
1343
|
+
baseRel = baseRel.slice(0, -ext.length);
|
|
1344
|
+
break;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
if (fileSet.has(baseRel)) return baseRel;
|
|
1348
|
+
for (const ext of RESOLUTION_EXT) {
|
|
1349
|
+
const c = baseRel + ext;
|
|
1350
|
+
if (fileSet.has(c)) return c;
|
|
1351
|
+
}
|
|
1352
|
+
for (const ext of RESOLUTION_EXT) {
|
|
1353
|
+
const c = path.posix.join(baseRel, "index" + ext);
|
|
1354
|
+
if (fileSet.has(c)) return c;
|
|
1355
|
+
}
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
async function parseTsconfigAliases(filePath, cwd) {
|
|
1359
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
1360
|
+
let json;
|
|
1361
|
+
try {
|
|
1362
|
+
const raw = await fs.readFile(filePath, "utf8");
|
|
1363
|
+
const stripped = raw.replace(/^\s*\/\/.*$/gm, "");
|
|
1364
|
+
json = JSON.parse(stripped);
|
|
1365
|
+
} catch {
|
|
1366
|
+
return aliases;
|
|
1367
|
+
}
|
|
1368
|
+
const baseUrl = json?.compilerOptions?.baseUrl ?? ".";
|
|
1369
|
+
const pathsMap = json?.compilerOptions?.paths ?? {};
|
|
1370
|
+
const absBase = path.resolve(path.dirname(filePath), baseUrl);
|
|
1371
|
+
const relBase = path.relative(cwd, absBase) || ".";
|
|
1372
|
+
for (const [key, vals] of Object.entries(pathsMap)) {
|
|
1373
|
+
if (!Array.isArray(vals) || vals.length === 0) continue;
|
|
1374
|
+
const cleanKey = key.replace(/\/\*$/, "");
|
|
1375
|
+
const cleanVal = vals[0].replace(/\/\*$/, "");
|
|
1376
|
+
aliases.set(cleanKey, path.join(relBase, cleanVal));
|
|
1377
|
+
}
|
|
1378
|
+
return aliases;
|
|
1379
|
+
}
|
|
1380
|
+
async function loadTsconfigs(cwd) {
|
|
1381
|
+
const scopes = [];
|
|
1382
|
+
let tsconfigPaths = [];
|
|
1383
|
+
try {
|
|
1384
|
+
const { stdout } = await execAsync(
|
|
1385
|
+
"git -c core.quotePath=false ls-files --cached --others --exclude-standard",
|
|
1386
|
+
{ cwd, maxBuffer: 50 * 1024 * 1024 }
|
|
1387
|
+
);
|
|
1388
|
+
tsconfigPaths = stdout.split("\n").map((p) => p.trim()).filter((p) => /(^|\/)tsconfig[^/]*\.json$/.test(p) && !p.includes("node_modules/"));
|
|
1389
|
+
} catch {
|
|
1390
|
+
try {
|
|
1391
|
+
await fs.access(path.join(cwd, "tsconfig.json"));
|
|
1392
|
+
tsconfigPaths = ["tsconfig.json"];
|
|
1393
|
+
} catch {
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
for (const rel of tsconfigPaths) {
|
|
1397
|
+
const aliases = await parseTsconfigAliases(path.join(cwd, rel), cwd);
|
|
1398
|
+
if (aliases.size === 0) continue;
|
|
1399
|
+
const scope = path.dirname(rel);
|
|
1400
|
+
scopes.push({
|
|
1401
|
+
scope: scope === "." ? "" : scope,
|
|
1402
|
+
aliases,
|
|
1403
|
+
sortedAliases: sortAliasesByLength(aliases)
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
let root = scopes.find((s) => s.scope === "");
|
|
1407
|
+
if (!root) {
|
|
1408
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
1409
|
+
root = { scope: "", aliases, sortedAliases: [] };
|
|
1410
|
+
scopes.push(root);
|
|
1411
|
+
}
|
|
1412
|
+
if (!root.aliases.has("@")) {
|
|
1413
|
+
root.aliases.set("@", "./src");
|
|
1414
|
+
root.sortedAliases = sortAliasesByLength(root.aliases);
|
|
1415
|
+
}
|
|
1416
|
+
return scopes.sort((a, b) => b.scope.length - a.scope.length);
|
|
1417
|
+
}
|
|
1418
|
+
function sortAliasesByLength(aliases) {
|
|
1419
|
+
return [...aliases.entries()].sort(([a], [b]) => b.length - a.length);
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// packages/feature/explorer/src/server/codeMap/handlers/typescript.ts
|
|
1423
|
+
import path2 from "path";
|
|
1424
|
+
|
|
1425
|
+
// packages/feature/explorer/src/server/codeMap/extractSymbols.ts
|
|
1426
|
+
function hashText(s) {
|
|
1427
|
+
let h1 = 3735928559;
|
|
1428
|
+
let h2 = 1103547991;
|
|
1429
|
+
for (let i = 0; i < s.length; i++) {
|
|
1430
|
+
const ch = s.charCodeAt(i);
|
|
1431
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
1432
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
1433
|
+
}
|
|
1434
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
1435
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
1436
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0) >>> 0).toString(16);
|
|
1437
|
+
}
|
|
1438
|
+
function normalizeForHash(s) {
|
|
1439
|
+
return s.replace(/\s+/g, " ").trim();
|
|
1440
|
+
}
|
|
1441
|
+
function qualify(parent, name) {
|
|
1442
|
+
return parent ? `${parent}>${name}` : name;
|
|
1443
|
+
}
|
|
1444
|
+
function nameOf(node) {
|
|
1445
|
+
const named = node.childForFieldName("name");
|
|
1446
|
+
if (named) return named.text;
|
|
1447
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
1448
|
+
const c = node.namedChild(i);
|
|
1449
|
+
if (c && (c.type === "identifier" || c.type === "type_identifier" || c.type === "property_identifier")) {
|
|
1450
|
+
return c.text;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
return "<anonymous>";
|
|
1454
|
+
}
|
|
1455
|
+
function makeSymbol(node, name, kind, parentQname, children = [], params) {
|
|
1456
|
+
return {
|
|
1457
|
+
qualifiedName: qualify(parentQname, name),
|
|
1458
|
+
name,
|
|
1459
|
+
kind,
|
|
1460
|
+
// tree-sitter rows are 0-based; we expose 1-based for UI alignment.
|
|
1461
|
+
startLine: node.startPosition.row + 1,
|
|
1462
|
+
endLine: node.endPosition.row + 1,
|
|
1463
|
+
contentHash: hashText(normalizeForHash(node.text)),
|
|
1464
|
+
children,
|
|
1465
|
+
params
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
function paramText(p) {
|
|
1469
|
+
switch (p.type) {
|
|
1470
|
+
case "required_parameter":
|
|
1471
|
+
case "optional_parameter": {
|
|
1472
|
+
const pat = p.childForFieldName("pattern");
|
|
1473
|
+
return pat ? paramText(pat) : p.text;
|
|
1474
|
+
}
|
|
1475
|
+
case "assignment_pattern": {
|
|
1476
|
+
const left = p.childForFieldName("left");
|
|
1477
|
+
return left ? paramText(left) : p.text;
|
|
1478
|
+
}
|
|
1479
|
+
case "default_parameter":
|
|
1480
|
+
case "typed_default_parameter": {
|
|
1481
|
+
const name = p.childForFieldName("name");
|
|
1482
|
+
return name ? name.text : p.text;
|
|
1483
|
+
}
|
|
1484
|
+
case "typed_parameter": {
|
|
1485
|
+
for (let i = 0; i < p.namedChildCount; i++) {
|
|
1486
|
+
const c = p.namedChild(i);
|
|
1487
|
+
if (c?.type === "identifier") return c.text;
|
|
1488
|
+
}
|
|
1489
|
+
return p.text;
|
|
1490
|
+
}
|
|
1491
|
+
// Identifiers, splat patterns, destructuring patterns — text as-is.
|
|
1492
|
+
default:
|
|
1493
|
+
return p.text;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
function extractParams(fnNode) {
|
|
1497
|
+
const single = fnNode.childForFieldName("parameter");
|
|
1498
|
+
if (single) return [single.text];
|
|
1499
|
+
const params = fnNode.childForFieldName("parameters");
|
|
1500
|
+
if (!params) return void 0;
|
|
1501
|
+
const out = [];
|
|
1502
|
+
for (let i = 0; i < params.namedChildCount; i++) {
|
|
1503
|
+
const p = params.namedChild(i);
|
|
1504
|
+
if (!p) continue;
|
|
1505
|
+
out.push(paramText(p));
|
|
1506
|
+
}
|
|
1507
|
+
return out;
|
|
1508
|
+
}
|
|
1509
|
+
function extractClassMembers(body, parentQname) {
|
|
1510
|
+
if (!body) return [];
|
|
1511
|
+
const out = [];
|
|
1512
|
+
for (let i = 0; i < body.namedChildCount; i++) {
|
|
1513
|
+
const m = body.namedChild(i);
|
|
1514
|
+
if (!m) continue;
|
|
1515
|
+
if (m.type === "method_definition") {
|
|
1516
|
+
out.push(
|
|
1517
|
+
makeSymbol(m, nameOf(m), "method", parentQname, [], extractParams(m))
|
|
1518
|
+
);
|
|
1519
|
+
} else if (m.type === "public_field_definition") {
|
|
1520
|
+
const value = m.childForFieldName("value");
|
|
1521
|
+
if (value && (value.type === "arrow_function" || value.type === "function_expression")) {
|
|
1522
|
+
out.push(
|
|
1523
|
+
makeSymbol(m, nameOf(m), "method", parentQname, [], extractParams(value))
|
|
1524
|
+
);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
return out;
|
|
1529
|
+
}
|
|
1530
|
+
function extractFromLexical(decl, parentQname, _isExported) {
|
|
1531
|
+
const out = [];
|
|
1532
|
+
for (let i = 0; i < decl.namedChildCount; i++) {
|
|
1533
|
+
const declarator = decl.namedChild(i);
|
|
1534
|
+
if (!declarator || declarator.type !== "variable_declarator") continue;
|
|
1535
|
+
const nameNode = declarator.childForFieldName("name");
|
|
1536
|
+
const valueNode = declarator.childForFieldName("value");
|
|
1537
|
+
if (!nameNode) continue;
|
|
1538
|
+
const name = nameNode.text;
|
|
1539
|
+
const isFn = valueNode && (valueNode.type === "arrow_function" || valueNode.type === "function_expression");
|
|
1540
|
+
const params = isFn && valueNode ? extractParams(valueNode) : void 0;
|
|
1541
|
+
out.push(
|
|
1542
|
+
makeSymbol(
|
|
1543
|
+
decl,
|
|
1544
|
+
name,
|
|
1545
|
+
isFn ? "function" : "const",
|
|
1546
|
+
parentQname,
|
|
1547
|
+
[],
|
|
1548
|
+
params
|
|
1549
|
+
)
|
|
1550
|
+
);
|
|
1551
|
+
if (valueNode && valueNode.type === "object" && !isFn) {
|
|
1552
|
+
const childParent = parentQname ? `${parentQname}>${name}` : name;
|
|
1553
|
+
for (let j = 0; j < valueNode.namedChildCount; j++) {
|
|
1554
|
+
const prop = valueNode.namedChild(j);
|
|
1555
|
+
if (!prop) continue;
|
|
1556
|
+
if (prop.type === "pair") {
|
|
1557
|
+
const keyNode = prop.childForFieldName("key");
|
|
1558
|
+
const valNode = prop.childForFieldName("value");
|
|
1559
|
+
if (!keyNode || !valNode) continue;
|
|
1560
|
+
if (keyNode.type !== "property_identifier" && keyNode.type !== "identifier") {
|
|
1561
|
+
continue;
|
|
1562
|
+
}
|
|
1563
|
+
if (valNode.type !== "arrow_function" && valNode.type !== "function_expression") {
|
|
1564
|
+
continue;
|
|
1565
|
+
}
|
|
1566
|
+
out.push(
|
|
1567
|
+
makeSymbol(
|
|
1568
|
+
prop,
|
|
1569
|
+
keyNode.text,
|
|
1570
|
+
"method",
|
|
1571
|
+
childParent,
|
|
1572
|
+
[],
|
|
1573
|
+
extractParams(valNode)
|
|
1574
|
+
)
|
|
1575
|
+
);
|
|
1576
|
+
} else if (prop.type === "method_definition") {
|
|
1577
|
+
const propName = nameOf(prop);
|
|
1578
|
+
if (propName) {
|
|
1579
|
+
out.push(
|
|
1580
|
+
makeSymbol(prop, propName, "method", childParent, [], extractParams(prop))
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
return out;
|
|
1588
|
+
}
|
|
1589
|
+
function extractFromNode(node, parentQname, isExported = false) {
|
|
1590
|
+
switch (node.type) {
|
|
1591
|
+
case "export_statement":
|
|
1592
|
+
case "export_default_declaration": {
|
|
1593
|
+
const out = [];
|
|
1594
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
1595
|
+
const inner = node.namedChild(i);
|
|
1596
|
+
if (inner) out.push(...extractFromNode(inner, parentQname, true));
|
|
1597
|
+
}
|
|
1598
|
+
return out;
|
|
1599
|
+
}
|
|
1600
|
+
case "function_declaration":
|
|
1601
|
+
case "generator_function_declaration": {
|
|
1602
|
+
return [
|
|
1603
|
+
makeSymbol(node, nameOf(node), "function", parentQname, [], extractParams(node))
|
|
1604
|
+
];
|
|
1605
|
+
}
|
|
1606
|
+
case "class_declaration":
|
|
1607
|
+
case "abstract_class_declaration": {
|
|
1608
|
+
const className = nameOf(node);
|
|
1609
|
+
const qname = qualify(parentQname, className);
|
|
1610
|
+
const body = node.childForFieldName("body");
|
|
1611
|
+
const members = extractClassMembers(body, qname);
|
|
1612
|
+
return [makeSymbol(node, className, "class", parentQname, members)];
|
|
1613
|
+
}
|
|
1614
|
+
case "interface_declaration": {
|
|
1615
|
+
return [makeSymbol(node, nameOf(node), "interface", parentQname)];
|
|
1616
|
+
}
|
|
1617
|
+
case "type_alias_declaration": {
|
|
1618
|
+
return [makeSymbol(node, nameOf(node), "type", parentQname)];
|
|
1619
|
+
}
|
|
1620
|
+
case "enum_declaration": {
|
|
1621
|
+
return [makeSymbol(node, nameOf(node), "enum", parentQname)];
|
|
1622
|
+
}
|
|
1623
|
+
case "lexical_declaration":
|
|
1624
|
+
case "variable_declaration": {
|
|
1625
|
+
return extractFromLexical(node, parentQname, isExported);
|
|
1626
|
+
}
|
|
1627
|
+
// ---- Python ------------------------------------------------------------
|
|
1628
|
+
case "function_definition": {
|
|
1629
|
+
return [
|
|
1630
|
+
makeSymbol(node, nameOf(node), "function", parentQname, [], extractParams(node))
|
|
1631
|
+
];
|
|
1632
|
+
}
|
|
1633
|
+
case "class_definition": {
|
|
1634
|
+
const className = nameOf(node);
|
|
1635
|
+
const qname = qualify(parentQname, className);
|
|
1636
|
+
const body = node.childForFieldName("body");
|
|
1637
|
+
const members = extractPythonClassMembers(body, qname);
|
|
1638
|
+
return [makeSymbol(node, className, "class", parentQname, members)];
|
|
1639
|
+
}
|
|
1640
|
+
case "decorated_definition": {
|
|
1641
|
+
const inner = node.childForFieldName("definition");
|
|
1642
|
+
if (!inner) return [];
|
|
1643
|
+
const innerSymbols = extractFromNode(inner, parentQname, false);
|
|
1644
|
+
return innerSymbols.map((s) => ({
|
|
1645
|
+
...s,
|
|
1646
|
+
startLine: node.startPosition.row + 1,
|
|
1647
|
+
// Re-hash from the decorated text so contentHash captures the
|
|
1648
|
+
// decorator change too. The simplest form: hash the outer node.
|
|
1649
|
+
contentHash: hashText(normalizeForHash(node.text))
|
|
1650
|
+
}));
|
|
1651
|
+
}
|
|
1652
|
+
case "expression_statement": {
|
|
1653
|
+
const out = [];
|
|
1654
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
1655
|
+
const c = node.namedChild(i);
|
|
1656
|
+
if (c?.type === "assignment") {
|
|
1657
|
+
const sym = extractPythonAssignment(node, c, parentQname);
|
|
1658
|
+
if (sym) out.push(sym);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
out.push(...extractFromCallStatement(node, parentQname));
|
|
1662
|
+
return out;
|
|
1663
|
+
}
|
|
1664
|
+
default:
|
|
1665
|
+
return [];
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
function extractFromCallStatement(node, parentQname) {
|
|
1669
|
+
let call = null;
|
|
1670
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
1671
|
+
const c = node.namedChild(i);
|
|
1672
|
+
if (!c) continue;
|
|
1673
|
+
if (c.type === "call_expression") {
|
|
1674
|
+
call = c;
|
|
1675
|
+
break;
|
|
1676
|
+
}
|
|
1677
|
+
if (c.type === "await_expression") {
|
|
1678
|
+
for (let j = 0; j < c.namedChildCount; j++) {
|
|
1679
|
+
const inner = c.namedChild(j);
|
|
1680
|
+
if (inner?.type === "call_expression") {
|
|
1681
|
+
call = inner;
|
|
1682
|
+
break;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
if (!call) return [];
|
|
1689
|
+
const callee = call.childForFieldName("function");
|
|
1690
|
+
const args = call.childForFieldName("arguments");
|
|
1691
|
+
if (!callee || !args) return [];
|
|
1692
|
+
let label = null;
|
|
1693
|
+
const fnArgs = [];
|
|
1694
|
+
for (let i = 0; i < args.namedChildCount; i++) {
|
|
1695
|
+
const arg = args.namedChild(i);
|
|
1696
|
+
if (!arg) continue;
|
|
1697
|
+
if (label === null && (arg.type === "string" || arg.type === "template_string")) {
|
|
1698
|
+
const t = arg.text;
|
|
1699
|
+
label = t.length >= 2 && /^["'`]/.test(t) ? t.slice(1, -1) : t;
|
|
1700
|
+
}
|
|
1701
|
+
if (arg.type === "arrow_function" || arg.type === "function_expression") {
|
|
1702
|
+
fnArgs.push(arg);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
if (fnArgs.length === 0 || !label) return [];
|
|
1706
|
+
const calleeName = leafCalleeName(callee);
|
|
1707
|
+
const baseName = calleeName ? `${calleeName} ${label}` : label;
|
|
1708
|
+
return fnArgs.map(
|
|
1709
|
+
(fnArg, i) => makeSymbol(
|
|
1710
|
+
fnArg,
|
|
1711
|
+
fnArgs.length > 1 ? `${baseName} #${i + 1}` : baseName,
|
|
1712
|
+
"function",
|
|
1713
|
+
parentQname,
|
|
1714
|
+
[],
|
|
1715
|
+
extractParams(fnArg)
|
|
1716
|
+
)
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
function extractPythonClassMembers(body, parentQname) {
|
|
1720
|
+
if (!body) return [];
|
|
1721
|
+
const out = [];
|
|
1722
|
+
for (let i = 0; i < body.namedChildCount; i++) {
|
|
1723
|
+
const m = body.namedChild(i);
|
|
1724
|
+
if (!m) continue;
|
|
1725
|
+
if (m.type === "function_definition") {
|
|
1726
|
+
out.push(
|
|
1727
|
+
makeSymbol(m, nameOf(m), "method", parentQname, [], extractParams(m))
|
|
1728
|
+
);
|
|
1729
|
+
} else if (m.type === "decorated_definition") {
|
|
1730
|
+
const inner = m.childForFieldName("definition");
|
|
1731
|
+
if (inner?.type === "function_definition") {
|
|
1732
|
+
out.push({
|
|
1733
|
+
...makeSymbol(inner, nameOf(inner), "method", parentQname, [], extractParams(inner)),
|
|
1734
|
+
startLine: m.startPosition.row + 1,
|
|
1735
|
+
contentHash: hashText(normalizeForHash(m.text))
|
|
1736
|
+
});
|
|
1737
|
+
} else if (inner?.type === "class_definition") {
|
|
1738
|
+
const innerName = nameOf(inner);
|
|
1739
|
+
const innerQname = qualify(parentQname, innerName);
|
|
1740
|
+
const innerBody = inner.childForFieldName("body");
|
|
1741
|
+
const nested = extractPythonClassMembers(innerBody, innerQname);
|
|
1742
|
+
out.push({
|
|
1743
|
+
...makeSymbol(inner, innerName, "class", parentQname, nested),
|
|
1744
|
+
startLine: m.startPosition.row + 1,
|
|
1745
|
+
contentHash: hashText(normalizeForHash(m.text))
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
} else if (m.type === "class_definition") {
|
|
1749
|
+
const innerName = nameOf(m);
|
|
1750
|
+
const innerQname = qualify(parentQname, innerName);
|
|
1751
|
+
const innerBody = m.childForFieldName("body");
|
|
1752
|
+
const nested = extractPythonClassMembers(innerBody, innerQname);
|
|
1753
|
+
out.push(makeSymbol(m, innerName, "class", parentQname, nested));
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return out;
|
|
1757
|
+
}
|
|
1758
|
+
function extractPythonAssignment(outer, assignment, parentQname) {
|
|
1759
|
+
const lhs = assignment.childForFieldName("left");
|
|
1760
|
+
if (!lhs || lhs.type !== "identifier") return null;
|
|
1761
|
+
const name = lhs.text;
|
|
1762
|
+
return {
|
|
1763
|
+
qualifiedName: qualify(parentQname, name),
|
|
1764
|
+
name,
|
|
1765
|
+
kind: "const",
|
|
1766
|
+
startLine: outer.startPosition.row + 1,
|
|
1767
|
+
endLine: outer.endPosition.row + 1,
|
|
1768
|
+
contentHash: hashText(normalizeForHash(outer.text)),
|
|
1769
|
+
children: []
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
function leafCalleeName(node) {
|
|
1773
|
+
if (node.type === "identifier") return node.text;
|
|
1774
|
+
if (node.type === "member_expression") {
|
|
1775
|
+
const prop = node.childForFieldName("property");
|
|
1776
|
+
return prop?.text ?? "";
|
|
1777
|
+
}
|
|
1778
|
+
if (node.type === "call_expression") {
|
|
1779
|
+
const fn = node.childForFieldName("function");
|
|
1780
|
+
return fn ? leafCalleeName(fn) : "";
|
|
1781
|
+
}
|
|
1782
|
+
return "";
|
|
1783
|
+
}
|
|
1784
|
+
function extractImportHeader(rootNode) {
|
|
1785
|
+
const headerNodes = [];
|
|
1786
|
+
let firstLine = -1;
|
|
1787
|
+
let lastLine = -1;
|
|
1788
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
1789
|
+
const c = rootNode.namedChild(i);
|
|
1790
|
+
if (!c) continue;
|
|
1791
|
+
const isHeader = (
|
|
1792
|
+
// JS/TS: `import X from 'y'`, `import 'y'`
|
|
1793
|
+
c.type === "import_statement" || // JS/TS: `export { x } from './y'` (re-export with `source` field)
|
|
1794
|
+
c.type === "export_statement" && c.childForFieldName("source") !== null || // Python: `from x import y` / `from .x import y`
|
|
1795
|
+
c.type === "import_from_statement" || // Python: `import x` / `import x.y as z`
|
|
1796
|
+
c.type === "future_import_statement"
|
|
1797
|
+
);
|
|
1798
|
+
if (isHeader) {
|
|
1799
|
+
headerNodes.push(c);
|
|
1800
|
+
if (firstLine < 0) firstLine = c.startPosition.row + 1;
|
|
1801
|
+
lastLine = c.endPosition.row + 1;
|
|
1802
|
+
} else if (firstLine >= 0) {
|
|
1803
|
+
break;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
if (firstLine < 0) return null;
|
|
1807
|
+
const text = headerNodes.map((n) => n.text).join("\n");
|
|
1808
|
+
return {
|
|
1809
|
+
qualifiedName: "__imports__",
|
|
1810
|
+
name: "imports",
|
|
1811
|
+
kind: "unknown",
|
|
1812
|
+
startLine: firstLine,
|
|
1813
|
+
endLine: lastLine,
|
|
1814
|
+
contentHash: hashText(normalizeForHash(text)),
|
|
1815
|
+
children: []
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
function computeFillerBlocks(rootNode, existing) {
|
|
1819
|
+
const source = rootNode.text;
|
|
1820
|
+
const lines = source.split("\n");
|
|
1821
|
+
const fileLineCount = lines.length;
|
|
1822
|
+
if (fileLineCount === 0) return [];
|
|
1823
|
+
const covered = new Uint8Array(fileLineCount + 2);
|
|
1824
|
+
for (const s of existing) {
|
|
1825
|
+
const lo = Math.max(1, s.startLine);
|
|
1826
|
+
const hi = Math.min(fileLineCount, s.endLine);
|
|
1827
|
+
for (let i = lo; i <= hi; i++) covered[i] = 1;
|
|
1828
|
+
}
|
|
1829
|
+
const fillers = [];
|
|
1830
|
+
const flush = (start, end) => {
|
|
1831
|
+
let hasContent = false;
|
|
1832
|
+
for (let i = start; i <= end; i++) {
|
|
1833
|
+
const ln = lines[i - 1];
|
|
1834
|
+
if (ln && ln.trim().length > 0) {
|
|
1835
|
+
hasContent = true;
|
|
1836
|
+
break;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
if (!hasContent) return;
|
|
1840
|
+
const text = lines.slice(start - 1, end).join("\n");
|
|
1841
|
+
fillers.push({
|
|
1842
|
+
qualifiedName: `__code_${start}_${end}__`,
|
|
1843
|
+
name: "code",
|
|
1844
|
+
kind: "unknown",
|
|
1845
|
+
startLine: start,
|
|
1846
|
+
endLine: end,
|
|
1847
|
+
contentHash: hashText(normalizeForHash(text)),
|
|
1848
|
+
children: []
|
|
1849
|
+
});
|
|
1850
|
+
};
|
|
1851
|
+
let runStart = -1;
|
|
1852
|
+
for (let i = 1; i <= fileLineCount; i++) {
|
|
1853
|
+
if (!covered[i]) {
|
|
1854
|
+
if (runStart < 0) runStart = i;
|
|
1855
|
+
} else if (runStart >= 0) {
|
|
1856
|
+
flush(runStart, i - 1);
|
|
1857
|
+
runStart = -1;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
if (runStart >= 0) flush(runStart, fileLineCount);
|
|
1861
|
+
return fillers;
|
|
1862
|
+
}
|
|
1863
|
+
function extractSymbolsFromTree(rootNode) {
|
|
1864
|
+
const out = [];
|
|
1865
|
+
const header = extractImportHeader(rootNode);
|
|
1866
|
+
if (header) out.push(header);
|
|
1867
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
1868
|
+
const child = rootNode.namedChild(i);
|
|
1869
|
+
if (child) out.push(...extractFromNode(child, void 0, false));
|
|
1870
|
+
}
|
|
1871
|
+
out.push(...computeFillerBlocks(rootNode, out));
|
|
1872
|
+
return out;
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
// packages/feature/explorer/src/server/codeMap/extractCalls.ts
|
|
1876
|
+
function extractRawCalls(root) {
|
|
1877
|
+
const out = [];
|
|
1878
|
+
function visit(node) {
|
|
1879
|
+
if (node.type === "call_expression" || node.type === "call") {
|
|
1880
|
+
const fn = node.childForFieldName("function");
|
|
1881
|
+
const name = calleeLeafName(fn);
|
|
1882
|
+
if (name) {
|
|
1883
|
+
const receiverName = receiverRootName(fn);
|
|
1884
|
+
out.push({
|
|
1885
|
+
calleeName: name,
|
|
1886
|
+
line: node.startPosition.row + 1,
|
|
1887
|
+
...receiverName ? { receiverName } : {}
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
} else if (node.type === "jsx_opening_element" || node.type === "jsx_self_closing_element") {
|
|
1891
|
+
const nameNode = node.childForFieldName("name");
|
|
1892
|
+
const name = jsxComponentName(nameNode);
|
|
1893
|
+
if (name) out.push({ calleeName: name, line: node.startPosition.row + 1 });
|
|
1894
|
+
}
|
|
1895
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
1896
|
+
const c = node.child(i);
|
|
1897
|
+
if (c) visit(c);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
visit(root);
|
|
1901
|
+
return out;
|
|
1902
|
+
}
|
|
1903
|
+
function receiverRootName(node) {
|
|
1904
|
+
if (!node) return void 0;
|
|
1905
|
+
if (node.type !== "member_expression" && node.type !== "attribute") {
|
|
1906
|
+
return void 0;
|
|
1907
|
+
}
|
|
1908
|
+
let cur = node;
|
|
1909
|
+
while (cur) {
|
|
1910
|
+
if (cur.type === "identifier") return cur.text;
|
|
1911
|
+
if (cur.type === "this" || cur.type === "super") return void 0;
|
|
1912
|
+
if (cur.type === "member_expression" || cur.type === "attribute") {
|
|
1913
|
+
cur = cur.childForFieldName("object");
|
|
1914
|
+
continue;
|
|
1915
|
+
}
|
|
1916
|
+
return void 0;
|
|
1917
|
+
}
|
|
1918
|
+
return void 0;
|
|
1919
|
+
}
|
|
1920
|
+
function calleeLeafName(node) {
|
|
1921
|
+
if (!node) return null;
|
|
1922
|
+
if (node.type === "identifier" || node.type === "shorthand_property_identifier") {
|
|
1923
|
+
return node.text;
|
|
1924
|
+
}
|
|
1925
|
+
if (node.type === "member_expression") {
|
|
1926
|
+
const prop = node.childForFieldName("property");
|
|
1927
|
+
return prop?.text ?? null;
|
|
1928
|
+
}
|
|
1929
|
+
if (node.type === "attribute") {
|
|
1930
|
+
const prop = node.childForFieldName("attribute");
|
|
1931
|
+
return prop?.text ?? null;
|
|
1932
|
+
}
|
|
1933
|
+
if (node.type === "call_expression" || node.type === "call") {
|
|
1934
|
+
return calleeLeafName(node.childForFieldName("function"));
|
|
1935
|
+
}
|
|
1936
|
+
return null;
|
|
1937
|
+
}
|
|
1938
|
+
function jsxComponentName(node) {
|
|
1939
|
+
if (!node) return null;
|
|
1940
|
+
if (node.type === "identifier") {
|
|
1941
|
+
return /^[A-Z]/.test(node.text) ? node.text : null;
|
|
1942
|
+
}
|
|
1943
|
+
if (node.type === "member_expression" || node.type === "jsx_member_expression") {
|
|
1944
|
+
const obj = node.childForFieldName("object") ?? node.namedChild(0);
|
|
1945
|
+
return jsxComponentName(obj);
|
|
1946
|
+
}
|
|
1947
|
+
return null;
|
|
1948
|
+
}
|
|
1949
|
+
function extractImportBindings(root) {
|
|
1950
|
+
const out = [];
|
|
1951
|
+
for (let i = 0; i < root.namedChildCount; i++) {
|
|
1952
|
+
const n = root.namedChild(i);
|
|
1953
|
+
if (!n) continue;
|
|
1954
|
+
if (n.type === "import_statement") {
|
|
1955
|
+
const src = n.childForFieldName("source");
|
|
1956
|
+
if (src) {
|
|
1957
|
+
extractJsTsBindings(n, src, out);
|
|
1958
|
+
} else {
|
|
1959
|
+
extractPythonImportBindings(n, out);
|
|
1960
|
+
}
|
|
1961
|
+
} else if (n.type === "import_from_statement") {
|
|
1962
|
+
extractPythonFromBindings(n, out);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
return out;
|
|
1966
|
+
}
|
|
1967
|
+
function extractJsTsBindings(n, src, out) {
|
|
1968
|
+
const specifier = stripQuotes(src.text);
|
|
1969
|
+
let clause = null;
|
|
1970
|
+
for (let j = 0; j < n.namedChildCount; j++) {
|
|
1971
|
+
const c = n.namedChild(j);
|
|
1972
|
+
if (c?.type === "import_clause") {
|
|
1973
|
+
clause = c;
|
|
1974
|
+
break;
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
if (!clause) return;
|
|
1978
|
+
for (let j = 0; j < clause.namedChildCount; j++) {
|
|
1979
|
+
const c = clause.namedChild(j);
|
|
1980
|
+
if (!c) continue;
|
|
1981
|
+
if (c.type === "identifier") {
|
|
1982
|
+
out.push({ specifier, importedName: "default", localName: c.text });
|
|
1983
|
+
} else if (c.type === "namespace_import") {
|
|
1984
|
+
const id = firstNamedChildOfType(c, "identifier");
|
|
1985
|
+
if (id) out.push({ specifier, importedName: "*", localName: id.text });
|
|
1986
|
+
} else if (c.type === "named_imports") {
|
|
1987
|
+
for (let k = 0; k < c.namedChildCount; k++) {
|
|
1988
|
+
const spec = c.namedChild(k);
|
|
1989
|
+
if (!spec || spec.type !== "import_specifier") continue;
|
|
1990
|
+
const nameNode = spec.childForFieldName("name");
|
|
1991
|
+
const aliasNode = spec.childForFieldName("alias");
|
|
1992
|
+
if (nameNode) {
|
|
1993
|
+
out.push({
|
|
1994
|
+
specifier,
|
|
1995
|
+
importedName: nameNode.text,
|
|
1996
|
+
localName: aliasNode?.text ?? nameNode.text
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
function extractPythonImportBindings(n, out) {
|
|
2004
|
+
for (let i = 0; i < n.childCount; i++) {
|
|
2005
|
+
const c = n.child(i);
|
|
2006
|
+
if (!c || n.fieldNameForChild(i) !== "name") continue;
|
|
2007
|
+
if (c.type === "dotted_name") {
|
|
2008
|
+
const spec = c.text;
|
|
2009
|
+
const local = spec.split(".")[0];
|
|
2010
|
+
out.push({ specifier: spec, importedName: "*", localName: local });
|
|
2011
|
+
} else if (c.type === "aliased_import") {
|
|
2012
|
+
const name = c.childForFieldName("name");
|
|
2013
|
+
const alias = c.childForFieldName("alias");
|
|
2014
|
+
if (name?.type === "dotted_name" && alias) {
|
|
2015
|
+
out.push({ specifier: name.text, importedName: "*", localName: alias.text });
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
function extractPythonFromBindings(n, out) {
|
|
2021
|
+
const moduleNode = n.childForFieldName("module_name");
|
|
2022
|
+
let specifier = "";
|
|
2023
|
+
if (moduleNode) {
|
|
2024
|
+
if (moduleNode.type === "dotted_name") {
|
|
2025
|
+
specifier = moduleNode.text;
|
|
2026
|
+
} else if (moduleNode.type === "relative_import") {
|
|
2027
|
+
let dots = "";
|
|
2028
|
+
let modulePath = "";
|
|
2029
|
+
for (let i = 0; i < moduleNode.namedChildCount; i++) {
|
|
2030
|
+
const c = moduleNode.namedChild(i);
|
|
2031
|
+
if (!c) continue;
|
|
2032
|
+
if (c.type === "import_prefix") dots = c.text;
|
|
2033
|
+
else if (c.type === "dotted_name") modulePath = c.text;
|
|
2034
|
+
}
|
|
2035
|
+
specifier = dots + modulePath;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
if (!specifier) return;
|
|
2039
|
+
let sawWildcard = false;
|
|
2040
|
+
for (let i = 0; i < n.childCount; i++) {
|
|
2041
|
+
const c = n.child(i);
|
|
2042
|
+
if (!c) continue;
|
|
2043
|
+
const field = n.fieldNameForChild(i);
|
|
2044
|
+
if (c.type === "wildcard_import") {
|
|
2045
|
+
sawWildcard = true;
|
|
2046
|
+
continue;
|
|
2047
|
+
}
|
|
2048
|
+
if (field !== "name") continue;
|
|
2049
|
+
if (c.type === "dotted_name") {
|
|
2050
|
+
const name = c.text;
|
|
2051
|
+
out.push({ specifier, importedName: name, localName: name });
|
|
2052
|
+
} else if (c.type === "aliased_import") {
|
|
2053
|
+
const name = c.childForFieldName("name");
|
|
2054
|
+
const alias = c.childForFieldName("alias");
|
|
2055
|
+
if (name?.type === "dotted_name" && alias) {
|
|
2056
|
+
out.push({
|
|
2057
|
+
specifier,
|
|
2058
|
+
importedName: name.text,
|
|
2059
|
+
localName: alias.text
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
if (sawWildcard) {
|
|
2065
|
+
out.push({ specifier, importedName: "*", localName: "*" });
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
function extractReexports(root) {
|
|
2069
|
+
const out = [];
|
|
2070
|
+
for (let i = 0; i < root.namedChildCount; i++) {
|
|
2071
|
+
const n = root.namedChild(i);
|
|
2072
|
+
if (!n || n.type !== "export_statement") continue;
|
|
2073
|
+
const src = n.childForFieldName("source");
|
|
2074
|
+
if (!src) continue;
|
|
2075
|
+
const specifier = stripQuotes(src.text);
|
|
2076
|
+
let clause = null;
|
|
2077
|
+
for (let j = 0; j < n.namedChildCount; j++) {
|
|
2078
|
+
const c = n.namedChild(j);
|
|
2079
|
+
if (c?.type === "export_clause") {
|
|
2080
|
+
clause = c;
|
|
2081
|
+
break;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
if (!clause) continue;
|
|
2085
|
+
for (let k = 0; k < clause.namedChildCount; k++) {
|
|
2086
|
+
const spec = clause.namedChild(k);
|
|
2087
|
+
if (!spec || spec.type !== "export_specifier") continue;
|
|
2088
|
+
const nameNode = spec.childForFieldName("name");
|
|
2089
|
+
const aliasNode = spec.childForFieldName("alias");
|
|
2090
|
+
if (!nameNode) continue;
|
|
2091
|
+
const originalName = nameNode.text;
|
|
2092
|
+
const exportedName = aliasNode?.text ?? originalName;
|
|
2093
|
+
out.push({
|
|
2094
|
+
localName: exportedName,
|
|
2095
|
+
specifier,
|
|
2096
|
+
importedName: originalName,
|
|
2097
|
+
isReexport: true
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
return out;
|
|
2102
|
+
}
|
|
2103
|
+
function stripQuotes(s) {
|
|
2104
|
+
if (s.length >= 2 && (s[0] === '"' || s[0] === "'") && s[s.length - 1] === s[0]) {
|
|
2105
|
+
return s.slice(1, -1);
|
|
2106
|
+
}
|
|
2107
|
+
return s;
|
|
2108
|
+
}
|
|
2109
|
+
function firstNamedChildOfType(node, type) {
|
|
2110
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
2111
|
+
const c = node.namedChild(i);
|
|
2112
|
+
if (c?.type === type) return c;
|
|
2113
|
+
}
|
|
2114
|
+
return null;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
// packages/feature/explorer/src/server/codeMap/projectGraph/extractImports.ts
|
|
2118
|
+
function walkForJsTsImports(root) {
|
|
2119
|
+
const out = [];
|
|
2120
|
+
function readStringNode(stringNode) {
|
|
2121
|
+
if (!stringNode || stringNode.type !== "string") return null;
|
|
2122
|
+
for (let i = 0; i < stringNode.namedChildCount; i++) {
|
|
2123
|
+
const c = stringNode.namedChild(i);
|
|
2124
|
+
if (c && c.type === "string_fragment") return c.text;
|
|
2125
|
+
}
|
|
2126
|
+
return "";
|
|
2127
|
+
}
|
|
2128
|
+
function visit(node) {
|
|
2129
|
+
switch (node.type) {
|
|
2130
|
+
case "import_statement":
|
|
2131
|
+
case "export_statement": {
|
|
2132
|
+
const source = node.childForFieldName("source");
|
|
2133
|
+
const spec = readStringNode(source);
|
|
2134
|
+
if (spec) out.push(spec);
|
|
2135
|
+
return;
|
|
2136
|
+
}
|
|
2137
|
+
case "call_expression": {
|
|
2138
|
+
const fn = node.childForFieldName("function");
|
|
2139
|
+
if (fn) {
|
|
2140
|
+
const isDynamicImport = fn.type === "import";
|
|
2141
|
+
const isRequire = fn.type === "identifier" && fn.text === "require";
|
|
2142
|
+
if (isDynamicImport || isRequire) {
|
|
2143
|
+
const args = node.childForFieldName("arguments");
|
|
2144
|
+
if (args && args.namedChildCount > 0) {
|
|
2145
|
+
const firstArg = args.namedChild(0);
|
|
2146
|
+
const spec = readStringNode(firstArg);
|
|
2147
|
+
if (spec) out.push(spec);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
break;
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
2155
|
+
const child = node.namedChild(i);
|
|
2156
|
+
if (child) visit(child);
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
visit(root);
|
|
2160
|
+
return out;
|
|
2161
|
+
}
|
|
2162
|
+
function walkForPythonImports(root) {
|
|
2163
|
+
const out = [];
|
|
2164
|
+
function visit(node) {
|
|
2165
|
+
switch (node.type) {
|
|
2166
|
+
case "import_statement": {
|
|
2167
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
2168
|
+
const c = node.child(i);
|
|
2169
|
+
if (!c || node.fieldNameForChild(i) !== "name") continue;
|
|
2170
|
+
if (c.type === "dotted_name") {
|
|
2171
|
+
out.push(c.text);
|
|
2172
|
+
} else if (c.type === "aliased_import") {
|
|
2173
|
+
const name = c.childForFieldName("name");
|
|
2174
|
+
if (name?.type === "dotted_name") out.push(name.text);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
return;
|
|
2178
|
+
}
|
|
2179
|
+
case "import_from_statement": {
|
|
2180
|
+
const spec = readPythonModuleSpec(node);
|
|
2181
|
+
if (spec) out.push(spec);
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
2186
|
+
const child = node.namedChild(i);
|
|
2187
|
+
if (child) visit(child);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
visit(root);
|
|
2191
|
+
return out;
|
|
2192
|
+
}
|
|
2193
|
+
function readPythonModuleSpec(node) {
|
|
2194
|
+
const moduleNode = node.childForFieldName("module_name");
|
|
2195
|
+
if (!moduleNode) return "";
|
|
2196
|
+
if (moduleNode.type === "dotted_name") return moduleNode.text;
|
|
2197
|
+
if (moduleNode.type === "relative_import") {
|
|
2198
|
+
let dots = "";
|
|
2199
|
+
let modulePath = "";
|
|
2200
|
+
for (let i = 0; i < moduleNode.namedChildCount; i++) {
|
|
2201
|
+
const c = moduleNode.namedChild(i);
|
|
2202
|
+
if (!c) continue;
|
|
2203
|
+
if (c.type === "import_prefix") dots = c.text;
|
|
2204
|
+
else if (c.type === "dotted_name") modulePath = c.text;
|
|
2205
|
+
}
|
|
2206
|
+
return dots + modulePath;
|
|
2207
|
+
}
|
|
2208
|
+
return "";
|
|
2209
|
+
}
|
|
2210
|
+
var WALKERS = {
|
|
2211
|
+
typescript: walkForJsTsImports,
|
|
2212
|
+
tsx: walkForJsTsImports,
|
|
2213
|
+
javascript: walkForJsTsImports,
|
|
2214
|
+
python: walkForPythonImports
|
|
2215
|
+
};
|
|
2216
|
+
function extractImportsFromTree(root, grammar) {
|
|
2217
|
+
const walker = WALKERS[grammar];
|
|
2218
|
+
if (!walker) return [];
|
|
2219
|
+
return walker(root);
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
// packages/feature/explorer/src/server/codeMap/handlers/typescript.ts
|
|
2223
|
+
function isFunctionLikeKind(k) {
|
|
2224
|
+
return k === "function" || k === "class" || k === "method";
|
|
2225
|
+
}
|
|
2226
|
+
var REEXPORT_MAX_DEPTH = 5;
|
|
2227
|
+
function findExportedSymbol(file, name, depth, visited, allFiles) {
|
|
2228
|
+
if (depth > REEXPORT_MAX_DEPTH) return null;
|
|
2229
|
+
if (visited.has(file.path)) return null;
|
|
2230
|
+
visited.add(file.path);
|
|
2231
|
+
const candidates = file.symbolsByName.get(name);
|
|
2232
|
+
if (candidates) {
|
|
2233
|
+
let best = null;
|
|
2234
|
+
for (const s of candidates) {
|
|
2235
|
+
if (!isFunctionLikeKind(s.kind)) continue;
|
|
2236
|
+
if (!best || s.endLine - s.startLine > best.endLine - best.startLine) {
|
|
2237
|
+
best = s;
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
if (best) return best;
|
|
2241
|
+
}
|
|
2242
|
+
const reexp = file.reexportsByLocalName.get(name);
|
|
2243
|
+
if (reexp) {
|
|
2244
|
+
const nextPath = file.resolvedImports.get(reexp.specifier);
|
|
2245
|
+
if (nextPath) {
|
|
2246
|
+
const nextFile = allFiles.get(nextPath);
|
|
2247
|
+
if (nextFile) {
|
|
2248
|
+
const found = findExportedSymbol(
|
|
2249
|
+
nextFile,
|
|
2250
|
+
reexp.importedName,
|
|
2251
|
+
depth + 1,
|
|
2252
|
+
visited,
|
|
2253
|
+
allFiles
|
|
2254
|
+
);
|
|
2255
|
+
if (found) return found;
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
return null;
|
|
2260
|
+
}
|
|
2261
|
+
function findReceiverMethod(file, receiverImportedName, methodName, depth, visited, allFiles) {
|
|
2262
|
+
if (depth > REEXPORT_MAX_DEPTH) return null;
|
|
2263
|
+
if (visited.has(file.path)) return null;
|
|
2264
|
+
visited.add(file.path);
|
|
2265
|
+
if (receiverImportedName !== "*") {
|
|
2266
|
+
const nestedQname = `${receiverImportedName}>${methodName}`;
|
|
2267
|
+
const nested = file.symbolsByQname.get(nestedQname);
|
|
2268
|
+
if (nested && isFunctionLikeKind(nested.kind)) return nested;
|
|
2269
|
+
}
|
|
2270
|
+
if (receiverImportedName === "*") {
|
|
2271
|
+
const top = file.symbolsByName.get(methodName);
|
|
2272
|
+
if (top) {
|
|
2273
|
+
let best = null;
|
|
2274
|
+
for (const s of top) {
|
|
2275
|
+
if (s.qualifiedName.includes(">")) continue;
|
|
2276
|
+
if (!isFunctionLikeKind(s.kind)) continue;
|
|
2277
|
+
if (!best || s.endLine - s.startLine > best.endLine - best.startLine) {
|
|
2278
|
+
best = s;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
if (best) return best;
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
const reexp = file.reexportsByLocalName.get(receiverImportedName);
|
|
2285
|
+
if (reexp) {
|
|
2286
|
+
const nextPath = file.resolvedImports.get(reexp.specifier);
|
|
2287
|
+
if (nextPath) {
|
|
2288
|
+
const nextFile = allFiles.get(nextPath);
|
|
2289
|
+
if (nextFile) {
|
|
2290
|
+
const found = findReceiverMethod(
|
|
2291
|
+
nextFile,
|
|
2292
|
+
reexp.importedName,
|
|
2293
|
+
methodName,
|
|
2294
|
+
depth + 1,
|
|
2295
|
+
visited,
|
|
2296
|
+
allFiles
|
|
2297
|
+
);
|
|
2298
|
+
if (found) return found;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
return null;
|
|
2303
|
+
}
|
|
2304
|
+
function makeTsFamilyHandler(grammarId, extensions) {
|
|
2305
|
+
return {
|
|
2306
|
+
grammarId,
|
|
2307
|
+
extensions,
|
|
2308
|
+
extractSymbols(root, _source) {
|
|
2309
|
+
return extractSymbolsFromTree(root);
|
|
2310
|
+
},
|
|
2311
|
+
extractImports(root) {
|
|
2312
|
+
const specs = extractImportsFromTree(root, grammarId);
|
|
2313
|
+
const baseBindings = extractImportBindings(root);
|
|
2314
|
+
const reexportBindings = extractReexports(root);
|
|
2315
|
+
return {
|
|
2316
|
+
specs,
|
|
2317
|
+
bindings: [...baseBindings, ...reexportBindings]
|
|
2318
|
+
};
|
|
2319
|
+
},
|
|
2320
|
+
extractCallSites(root, _symbols) {
|
|
2321
|
+
return extractRawCalls(root);
|
|
2322
|
+
},
|
|
2323
|
+
// ----------------------------------------------------------------
|
|
2324
|
+
// Project context — loads tsconfig path aliases + workspace
|
|
2325
|
+
// packages so resolveSpecifier can match aliased imports
|
|
2326
|
+
// (`@/foo`, `@org/auth`) without re-reading filesystem on every
|
|
2327
|
+
// resolve. Async because both loaders read JSON files.
|
|
2328
|
+
// ----------------------------------------------------------------
|
|
2329
|
+
async buildProjectContext(cwd, fileSet) {
|
|
2330
|
+
const mutableFileSet = new Set(fileSet);
|
|
2331
|
+
const tsconfigs = await loadTsconfigs(cwd);
|
|
2332
|
+
const workspaces = await loadWorkspaces(cwd, mutableFileSet);
|
|
2333
|
+
const sortedWsNames = [...workspaces.keys()].sort(
|
|
2334
|
+
(a, b) => b.length - a.length
|
|
2335
|
+
);
|
|
2336
|
+
const ctx = {
|
|
2337
|
+
cwd,
|
|
2338
|
+
tsconfigs,
|
|
2339
|
+
workspaces,
|
|
2340
|
+
sortedWsNames,
|
|
2341
|
+
owningScopesCache: /* @__PURE__ */ new Map()
|
|
2342
|
+
};
|
|
2343
|
+
return ctx;
|
|
2344
|
+
},
|
|
2345
|
+
resolveSpecifier(spec, fromFilePath, ctx, fileSet) {
|
|
2346
|
+
const c = ctx;
|
|
2347
|
+
const mutableFileSet = fileSet;
|
|
2348
|
+
let owningScopes = c.owningScopesCache.get(fromFilePath);
|
|
2349
|
+
if (!owningScopes) {
|
|
2350
|
+
owningScopes = c.tsconfigs.filter(
|
|
2351
|
+
(t) => fileInScope(fromFilePath, t.scope)
|
|
2352
|
+
);
|
|
2353
|
+
c.owningScopesCache.set(fromFilePath, owningScopes);
|
|
2354
|
+
}
|
|
2355
|
+
if (spec.startsWith("./") || spec.startsWith("../")) {
|
|
2356
|
+
return findFileForBase(
|
|
2357
|
+
path2.resolve(c.cwd, path2.dirname(fromFilePath), spec),
|
|
2358
|
+
c.cwd,
|
|
2359
|
+
mutableFileSet
|
|
2360
|
+
);
|
|
2361
|
+
}
|
|
2362
|
+
if (spec.startsWith("/")) {
|
|
2363
|
+
return findFileForBase(
|
|
2364
|
+
path2.resolve(c.cwd, spec.slice(1)),
|
|
2365
|
+
c.cwd,
|
|
2366
|
+
mutableFileSet
|
|
2367
|
+
);
|
|
2368
|
+
}
|
|
2369
|
+
for (const ts of owningScopes) {
|
|
2370
|
+
const hit = ts.sortedAliases.find(
|
|
2371
|
+
([prefix2]) => spec === prefix2 || spec.startsWith(prefix2 + "/")
|
|
2372
|
+
);
|
|
2373
|
+
if (!hit) continue;
|
|
2374
|
+
const [prefix, target] = hit;
|
|
2375
|
+
const remainder = spec === prefix ? "" : spec.slice(prefix.length + 1);
|
|
2376
|
+
const r = findFileForBase(
|
|
2377
|
+
path2.resolve(c.cwd, target, remainder),
|
|
2378
|
+
c.cwd,
|
|
2379
|
+
mutableFileSet
|
|
2380
|
+
);
|
|
2381
|
+
if (r) return r;
|
|
2382
|
+
}
|
|
2383
|
+
for (const pkgName of c.sortedWsNames) {
|
|
2384
|
+
if (spec !== pkgName && !spec.startsWith(pkgName + "/")) continue;
|
|
2385
|
+
const ws = c.workspaces.get(pkgName);
|
|
2386
|
+
if (spec === pkgName) return ws.entryFile;
|
|
2387
|
+
const subpath = spec.slice(pkgName.length + 1);
|
|
2388
|
+
return findFileRelativeToProject(
|
|
2389
|
+
path2.posix.join(ws.dir, subpath),
|
|
2390
|
+
mutableFileSet
|
|
2391
|
+
) ?? findFileRelativeToProject(
|
|
2392
|
+
path2.posix.join(ws.dir, "src", subpath),
|
|
2393
|
+
mutableFileSet
|
|
2394
|
+
);
|
|
2395
|
+
}
|
|
2396
|
+
return null;
|
|
2397
|
+
},
|
|
2398
|
+
resolveCall(call, from, fromFile, allFiles, _ctx) {
|
|
2399
|
+
if (call.receiverName) {
|
|
2400
|
+
const recvBinding = fromFile.bindingsByLocalName.get(call.receiverName);
|
|
2401
|
+
if (!recvBinding) return [];
|
|
2402
|
+
const recvFilePath = fromFile.resolvedImports.get(recvBinding.specifier);
|
|
2403
|
+
if (!recvFilePath) return [];
|
|
2404
|
+
const recvTarget = allFiles.get(recvFilePath);
|
|
2405
|
+
if (!recvTarget) return [];
|
|
2406
|
+
const sym2 = findReceiverMethod(
|
|
2407
|
+
recvTarget,
|
|
2408
|
+
recvBinding.importedName,
|
|
2409
|
+
call.calleeName,
|
|
2410
|
+
0,
|
|
2411
|
+
/* @__PURE__ */ new Set(),
|
|
2412
|
+
allFiles
|
|
2413
|
+
);
|
|
2414
|
+
if (sym2) {
|
|
2415
|
+
return [
|
|
2416
|
+
{
|
|
2417
|
+
kind: "symbol",
|
|
2418
|
+
addr: { filePath: sym2.filePath, qualifiedName: sym2.qualifiedName }
|
|
2419
|
+
}
|
|
2420
|
+
];
|
|
2421
|
+
}
|
|
2422
|
+
return [
|
|
2423
|
+
{
|
|
2424
|
+
kind: "method-unresolved",
|
|
2425
|
+
receiverName: call.receiverName,
|
|
2426
|
+
methodName: call.calleeName
|
|
2427
|
+
}
|
|
2428
|
+
];
|
|
2429
|
+
}
|
|
2430
|
+
const localMatches = fromFile.symbolsByName.get(call.calleeName);
|
|
2431
|
+
if (localMatches && localMatches.length > 0) {
|
|
2432
|
+
const out = [];
|
|
2433
|
+
for (const callee of localMatches) {
|
|
2434
|
+
if (callee.qualifiedName === from.qualifiedName) continue;
|
|
2435
|
+
if (!isFunctionLikeKind(callee.kind)) continue;
|
|
2436
|
+
out.push({
|
|
2437
|
+
kind: "symbol",
|
|
2438
|
+
addr: {
|
|
2439
|
+
filePath: callee.filePath,
|
|
2440
|
+
qualifiedName: callee.qualifiedName
|
|
2441
|
+
}
|
|
2442
|
+
});
|
|
2443
|
+
}
|
|
2444
|
+
return out;
|
|
2445
|
+
}
|
|
2446
|
+
const binding = fromFile.bindingsByLocalName.get(call.calleeName);
|
|
2447
|
+
if (!binding) return [];
|
|
2448
|
+
const targetFile = fromFile.resolvedImports.get(binding.specifier);
|
|
2449
|
+
if (!targetFile) {
|
|
2450
|
+
return [
|
|
2451
|
+
{
|
|
2452
|
+
kind: "external",
|
|
2453
|
+
name: binding.importedName,
|
|
2454
|
+
packageSpec: binding.specifier
|
|
2455
|
+
}
|
|
2456
|
+
];
|
|
2457
|
+
}
|
|
2458
|
+
const target = allFiles.get(targetFile);
|
|
2459
|
+
if (!target) return [];
|
|
2460
|
+
const sym = findExportedSymbol(
|
|
2461
|
+
target,
|
|
2462
|
+
binding.importedName,
|
|
2463
|
+
0,
|
|
2464
|
+
/* @__PURE__ */ new Set(),
|
|
2465
|
+
allFiles
|
|
2466
|
+
);
|
|
2467
|
+
if (!sym) return [];
|
|
2468
|
+
return [
|
|
2469
|
+
{
|
|
2470
|
+
kind: "symbol",
|
|
2471
|
+
addr: { filePath: sym.filePath, qualifiedName: sym.qualifiedName }
|
|
2472
|
+
}
|
|
2473
|
+
];
|
|
2474
|
+
},
|
|
2475
|
+
moduleForFile(filePath, _ctx) {
|
|
2476
|
+
return filePath;
|
|
2477
|
+
}
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
var typescriptHandler = makeTsFamilyHandler("typescript", [".ts"]);
|
|
2481
|
+
var tsxHandler = makeTsFamilyHandler("tsx", [".tsx", ".jsx"]);
|
|
2482
|
+
var javascriptHandler = makeTsFamilyHandler("javascript", [
|
|
2483
|
+
".js",
|
|
2484
|
+
".mjs",
|
|
2485
|
+
".cjs"
|
|
2486
|
+
]);
|
|
2487
|
+
|
|
2488
|
+
// packages/feature/explorer/src/server/codeMap/handlers/python.ts
|
|
2489
|
+
import path3 from "path";
|
|
2490
|
+
function isFunctionLikeKind2(k) {
|
|
2491
|
+
return k === "function" || k === "class" || k === "method";
|
|
2492
|
+
}
|
|
2493
|
+
function findExportedSymbolPy(file, name) {
|
|
2494
|
+
const candidates = file.symbolsByName.get(name);
|
|
2495
|
+
if (!candidates) return null;
|
|
2496
|
+
let best = null;
|
|
2497
|
+
for (const s of candidates) {
|
|
2498
|
+
if (!isFunctionLikeKind2(s.kind)) continue;
|
|
2499
|
+
if (!best || s.endLine - s.startLine > best.endLine - best.startLine) {
|
|
2500
|
+
best = s;
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
return best;
|
|
2504
|
+
}
|
|
2505
|
+
function findReceiverMethodPy(file, receiverImportedName, methodName) {
|
|
2506
|
+
if (receiverImportedName !== "*") {
|
|
2507
|
+
const nestedQname = `${receiverImportedName}>${methodName}`;
|
|
2508
|
+
const nested = file.symbolsByQname.get(nestedQname);
|
|
2509
|
+
if (nested && isFunctionLikeKind2(nested.kind)) return nested;
|
|
2510
|
+
}
|
|
2511
|
+
if (receiverImportedName === "*") {
|
|
2512
|
+
const top = file.symbolsByName.get(methodName);
|
|
2513
|
+
if (top) {
|
|
2514
|
+
let best = null;
|
|
2515
|
+
for (const s of top) {
|
|
2516
|
+
if (s.qualifiedName.includes(">")) continue;
|
|
2517
|
+
if (!isFunctionLikeKind2(s.kind)) continue;
|
|
2518
|
+
if (!best || s.endLine - s.startLine > best.endLine - best.startLine) {
|
|
2519
|
+
best = s;
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
if (best) return best;
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
return null;
|
|
2526
|
+
}
|
|
2527
|
+
function tryPythonPaths(baseDir, modulePath, fileSet) {
|
|
2528
|
+
const sub = modulePath.replace(/\./g, "/");
|
|
2529
|
+
const join2 = (...segs) => segs.filter((s) => s !== "" && s !== ".").join("/");
|
|
2530
|
+
if (!sub) {
|
|
2531
|
+
const init = join2(baseDir, "__init__.py");
|
|
2532
|
+
if (fileSet.has(init)) return init;
|
|
2533
|
+
return null;
|
|
2534
|
+
}
|
|
2535
|
+
const direct = join2(baseDir, sub + ".py");
|
|
2536
|
+
if (fileSet.has(direct)) return direct;
|
|
2537
|
+
const initFile = join2(baseDir, sub, "__init__.py");
|
|
2538
|
+
if (fileSet.has(initFile)) return initFile;
|
|
2539
|
+
return null;
|
|
2540
|
+
}
|
|
2541
|
+
var pythonHandler = {
|
|
2542
|
+
grammarId: "python",
|
|
2543
|
+
extensions: [".py", ".pyi"],
|
|
2544
|
+
extractSymbols(root, _source) {
|
|
2545
|
+
return extractSymbolsFromTree(root);
|
|
2546
|
+
},
|
|
2547
|
+
extractImports(root) {
|
|
2548
|
+
const specs = extractImportsFromTree(root, "python");
|
|
2549
|
+
const bindings = extractImportBindings(root);
|
|
2550
|
+
return { specs, bindings };
|
|
2551
|
+
},
|
|
2552
|
+
extractCallSites(root, _symbols) {
|
|
2553
|
+
return extractRawCalls(root);
|
|
2554
|
+
},
|
|
2555
|
+
buildProjectContext(cwd, fileSet) {
|
|
2556
|
+
const pythonRoots = [cwd];
|
|
2557
|
+
let hasSrcLayout = false;
|
|
2558
|
+
if (fileSet.has("src/__init__.py")) {
|
|
2559
|
+
hasSrcLayout = true;
|
|
2560
|
+
} else {
|
|
2561
|
+
for (const p of fileSet) {
|
|
2562
|
+
if (p.startsWith("src/") && p.endsWith(".py")) {
|
|
2563
|
+
hasSrcLayout = true;
|
|
2564
|
+
break;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
if (hasSrcLayout) pythonRoots.push(path3.join(cwd, "src"));
|
|
2569
|
+
const ctx = { cwd, pythonRoots };
|
|
2570
|
+
return ctx;
|
|
2571
|
+
},
|
|
2572
|
+
resolveSpecifier(spec, fromFilePath, ctx, fileSet) {
|
|
2573
|
+
const c = ctx;
|
|
2574
|
+
const dotMatch = /^(\.+)/.exec(spec);
|
|
2575
|
+
if (dotMatch) {
|
|
2576
|
+
const dots = dotMatch[1].length;
|
|
2577
|
+
const rest = spec.slice(dots);
|
|
2578
|
+
let baseDir = path3.dirname(fromFilePath);
|
|
2579
|
+
for (let i = 1; i < dots; i++) baseDir = path3.dirname(baseDir);
|
|
2580
|
+
return tryPythonPaths(baseDir || ".", rest, fileSet);
|
|
2581
|
+
}
|
|
2582
|
+
for (const root of c.pythonRoots) {
|
|
2583
|
+
const rootRel = path3.relative(c.cwd, root) || ".";
|
|
2584
|
+
const r = tryPythonPaths(rootRel, spec, fileSet);
|
|
2585
|
+
if (r) return r;
|
|
2586
|
+
}
|
|
2587
|
+
return null;
|
|
2588
|
+
},
|
|
2589
|
+
resolveCall(call, from, fromFile, allFiles, _ctx) {
|
|
2590
|
+
if (call.receiverName) {
|
|
2591
|
+
const recvBinding = fromFile.bindingsByLocalName.get(call.receiverName);
|
|
2592
|
+
if (!recvBinding) return [];
|
|
2593
|
+
const recvFilePath = fromFile.resolvedImports.get(recvBinding.specifier);
|
|
2594
|
+
if (!recvFilePath) return [];
|
|
2595
|
+
const recvTarget = allFiles.get(recvFilePath);
|
|
2596
|
+
if (!recvTarget) return [];
|
|
2597
|
+
const sym2 = findReceiverMethodPy(
|
|
2598
|
+
recvTarget,
|
|
2599
|
+
recvBinding.importedName,
|
|
2600
|
+
call.calleeName
|
|
2601
|
+
);
|
|
2602
|
+
if (sym2) {
|
|
2603
|
+
return [
|
|
2604
|
+
{
|
|
2605
|
+
kind: "symbol",
|
|
2606
|
+
addr: { filePath: sym2.filePath, qualifiedName: sym2.qualifiedName }
|
|
2607
|
+
}
|
|
2608
|
+
];
|
|
2609
|
+
}
|
|
2610
|
+
return [
|
|
2611
|
+
{
|
|
2612
|
+
kind: "method-unresolved",
|
|
2613
|
+
receiverName: call.receiverName,
|
|
2614
|
+
methodName: call.calleeName
|
|
2615
|
+
}
|
|
2616
|
+
];
|
|
2617
|
+
}
|
|
2618
|
+
const localMatches = fromFile.symbolsByName.get(call.calleeName);
|
|
2619
|
+
if (localMatches && localMatches.length > 0) {
|
|
2620
|
+
const out = [];
|
|
2621
|
+
for (const callee of localMatches) {
|
|
2622
|
+
if (callee.qualifiedName === from.qualifiedName) continue;
|
|
2623
|
+
if (!isFunctionLikeKind2(callee.kind)) continue;
|
|
2624
|
+
out.push({
|
|
2625
|
+
kind: "symbol",
|
|
2626
|
+
addr: {
|
|
2627
|
+
filePath: callee.filePath,
|
|
2628
|
+
qualifiedName: callee.qualifiedName
|
|
2629
|
+
}
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2632
|
+
return out;
|
|
2633
|
+
}
|
|
2634
|
+
const binding = fromFile.bindingsByLocalName.get(call.calleeName);
|
|
2635
|
+
if (!binding) return [];
|
|
2636
|
+
const targetFile = fromFile.resolvedImports.get(binding.specifier);
|
|
2637
|
+
if (!targetFile) {
|
|
2638
|
+
return [
|
|
2639
|
+
{
|
|
2640
|
+
kind: "external",
|
|
2641
|
+
name: binding.importedName,
|
|
2642
|
+
packageSpec: binding.specifier
|
|
2643
|
+
}
|
|
2644
|
+
];
|
|
2645
|
+
}
|
|
2646
|
+
const target = allFiles.get(targetFile);
|
|
2647
|
+
if (!target) return [];
|
|
2648
|
+
const sym = findExportedSymbolPy(target, binding.importedName);
|
|
2649
|
+
if (!sym) return [];
|
|
2650
|
+
return [
|
|
2651
|
+
{
|
|
2652
|
+
kind: "symbol",
|
|
2653
|
+
addr: { filePath: sym.filePath, qualifiedName: sym.qualifiedName }
|
|
2654
|
+
}
|
|
2655
|
+
];
|
|
2656
|
+
},
|
|
2657
|
+
moduleForFile(filePath, _ctx) {
|
|
2658
|
+
return filePath;
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2661
|
+
|
|
2662
|
+
// packages/feature/explorer/src/server/codeMap/handlers/go.ts
|
|
2663
|
+
import { promises as fs2 } from "fs";
|
|
2664
|
+
import path4 from "path";
|
|
2665
|
+
function qualify2(parent, name) {
|
|
2666
|
+
return parent ? `${parent}>${name}` : name;
|
|
2667
|
+
}
|
|
2668
|
+
function makeSymbol2(node, name, kind, parentQname, children = [], params) {
|
|
2669
|
+
return {
|
|
2670
|
+
qualifiedName: qualify2(parentQname, name),
|
|
2671
|
+
name,
|
|
2672
|
+
kind,
|
|
2673
|
+
startLine: node.startPosition.row + 1,
|
|
2674
|
+
endLine: node.endPosition.row + 1,
|
|
2675
|
+
contentHash: hashText(normalizeForHash(node.text)),
|
|
2676
|
+
children,
|
|
2677
|
+
params
|
|
2678
|
+
};
|
|
2679
|
+
}
|
|
2680
|
+
function extractGoParams(fnNode) {
|
|
2681
|
+
const params = fnNode.childForFieldName("parameters");
|
|
2682
|
+
if (!params) return void 0;
|
|
2683
|
+
const out = [];
|
|
2684
|
+
for (let i = 0; i < params.namedChildCount; i++) {
|
|
2685
|
+
const p = params.namedChild(i);
|
|
2686
|
+
if (!p) continue;
|
|
2687
|
+
if (p.type === "parameter_declaration") {
|
|
2688
|
+
const nameNode = p.childForFieldName("name");
|
|
2689
|
+
if (!nameNode) {
|
|
2690
|
+
out.push("_");
|
|
2691
|
+
continue;
|
|
2692
|
+
}
|
|
2693
|
+
if (nameNode.type === "identifier") {
|
|
2694
|
+
out.push(nameNode.text);
|
|
2695
|
+
} else if (nameNode.type === "identifier_list") {
|
|
2696
|
+
for (let j = 0; j < nameNode.namedChildCount; j++) {
|
|
2697
|
+
const id = nameNode.namedChild(j);
|
|
2698
|
+
if (id?.type === "identifier") out.push(id.text);
|
|
2699
|
+
}
|
|
2700
|
+
} else {
|
|
2701
|
+
out.push(nameNode.text);
|
|
2702
|
+
}
|
|
2703
|
+
} else if (p.type === "variadic_parameter_declaration") {
|
|
2704
|
+
const nameNode = p.childForFieldName("name");
|
|
2705
|
+
if (nameNode?.type === "identifier") {
|
|
2706
|
+
out.push(`...${nameNode.text}`);
|
|
2707
|
+
} else {
|
|
2708
|
+
out.push("...");
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
return out;
|
|
2713
|
+
}
|
|
2714
|
+
function extractReceiverTypeName(method) {
|
|
2715
|
+
const receiver = method.childForFieldName("receiver");
|
|
2716
|
+
if (!receiver) return null;
|
|
2717
|
+
for (let i = 0; i < receiver.namedChildCount; i++) {
|
|
2718
|
+
const p = receiver.namedChild(i);
|
|
2719
|
+
if (p?.type !== "parameter_declaration") continue;
|
|
2720
|
+
const t = p.childForFieldName("type");
|
|
2721
|
+
if (!t) return null;
|
|
2722
|
+
return readReceiverTypeIdentifier(t);
|
|
2723
|
+
}
|
|
2724
|
+
return null;
|
|
2725
|
+
}
|
|
2726
|
+
function readReceiverTypeIdentifier(t) {
|
|
2727
|
+
if (t.type === "type_identifier") return t.text;
|
|
2728
|
+
if (t.type === "pointer_type") {
|
|
2729
|
+
for (let i = 0; i < t.namedChildCount; i++) {
|
|
2730
|
+
const inner = t.namedChild(i);
|
|
2731
|
+
if (inner) {
|
|
2732
|
+
const r = readReceiverTypeIdentifier(inner);
|
|
2733
|
+
if (r) return r;
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
return null;
|
|
2737
|
+
}
|
|
2738
|
+
if (t.type === "generic_type") {
|
|
2739
|
+
const base = t.childForFieldName("type");
|
|
2740
|
+
if (base) return readReceiverTypeIdentifier(base);
|
|
2741
|
+
}
|
|
2742
|
+
return null;
|
|
2743
|
+
}
|
|
2744
|
+
function extractTypeDeclaration(decl, parentQname) {
|
|
2745
|
+
const out = [];
|
|
2746
|
+
for (let i = 0; i < decl.namedChildCount; i++) {
|
|
2747
|
+
const spec = decl.namedChild(i);
|
|
2748
|
+
if (!spec) continue;
|
|
2749
|
+
if (spec.type === "type_spec" || spec.type === "type_alias") {
|
|
2750
|
+
const nameNode = spec.childForFieldName("name");
|
|
2751
|
+
const typeNode = spec.childForFieldName("type");
|
|
2752
|
+
if (!nameNode) continue;
|
|
2753
|
+
const name = nameNode.text;
|
|
2754
|
+
const kind = typeNode?.type === "interface_type" ? "interface" : "class";
|
|
2755
|
+
out.push(makeSymbol2(spec, name, kind, parentQname));
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
return out;
|
|
2759
|
+
}
|
|
2760
|
+
function extractValueDeclaration(decl, parentQname) {
|
|
2761
|
+
const out = [];
|
|
2762
|
+
for (let i = 0; i < decl.namedChildCount; i++) {
|
|
2763
|
+
const spec = decl.namedChild(i);
|
|
2764
|
+
if (!spec) continue;
|
|
2765
|
+
if (spec.type === "var_spec" || spec.type === "const_spec") {
|
|
2766
|
+
const nameNode = spec.childForFieldName("name");
|
|
2767
|
+
if (!nameNode) continue;
|
|
2768
|
+
if (nameNode.type === "identifier_list") {
|
|
2769
|
+
for (let j = 0; j < nameNode.namedChildCount; j++) {
|
|
2770
|
+
const id = nameNode.namedChild(j);
|
|
2771
|
+
if (id?.type === "identifier") {
|
|
2772
|
+
out.push(makeSymbol2(spec, id.text, "const", parentQname));
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
} else if (nameNode.type === "identifier") {
|
|
2776
|
+
out.push(makeSymbol2(spec, nameNode.text, "const", parentQname));
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
return out;
|
|
2781
|
+
}
|
|
2782
|
+
function extractGoImportHeader(rootNode) {
|
|
2783
|
+
const headerNodes = [];
|
|
2784
|
+
let firstLine = -1;
|
|
2785
|
+
let lastLine = -1;
|
|
2786
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
2787
|
+
const c = rootNode.namedChild(i);
|
|
2788
|
+
if (!c) continue;
|
|
2789
|
+
if (c.type === "import_declaration") {
|
|
2790
|
+
headerNodes.push(c);
|
|
2791
|
+
if (firstLine < 0) firstLine = c.startPosition.row + 1;
|
|
2792
|
+
lastLine = c.endPosition.row + 1;
|
|
2793
|
+
} else if (c.type === "package_clause") {
|
|
2794
|
+
continue;
|
|
2795
|
+
} else if (firstLine >= 0) {
|
|
2796
|
+
break;
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
if (firstLine < 0) return null;
|
|
2800
|
+
const text = headerNodes.map((n) => n.text).join("\n");
|
|
2801
|
+
return {
|
|
2802
|
+
qualifiedName: "__imports__",
|
|
2803
|
+
name: "imports",
|
|
2804
|
+
kind: "unknown",
|
|
2805
|
+
startLine: firstLine,
|
|
2806
|
+
endLine: lastLine,
|
|
2807
|
+
contentHash: hashText(normalizeForHash(text)),
|
|
2808
|
+
children: []
|
|
2809
|
+
};
|
|
2810
|
+
}
|
|
2811
|
+
function extractTopLevel(rootNode) {
|
|
2812
|
+
const symbols = [];
|
|
2813
|
+
const pendingMethods = [];
|
|
2814
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
2815
|
+
const node = rootNode.namedChild(i);
|
|
2816
|
+
if (!node) continue;
|
|
2817
|
+
switch (node.type) {
|
|
2818
|
+
case "function_declaration": {
|
|
2819
|
+
const nameNode = node.childForFieldName("name");
|
|
2820
|
+
if (!nameNode) break;
|
|
2821
|
+
symbols.push(
|
|
2822
|
+
makeSymbol2(
|
|
2823
|
+
node,
|
|
2824
|
+
nameNode.text,
|
|
2825
|
+
"function",
|
|
2826
|
+
void 0,
|
|
2827
|
+
[],
|
|
2828
|
+
extractGoParams(node)
|
|
2829
|
+
)
|
|
2830
|
+
);
|
|
2831
|
+
break;
|
|
2832
|
+
}
|
|
2833
|
+
case "method_declaration": {
|
|
2834
|
+
const nameNode = node.childForFieldName("name");
|
|
2835
|
+
if (!nameNode) break;
|
|
2836
|
+
const recvType = extractReceiverTypeName(node);
|
|
2837
|
+
const sym = makeSymbol2(
|
|
2838
|
+
node,
|
|
2839
|
+
nameNode.text,
|
|
2840
|
+
"method",
|
|
2841
|
+
recvType ?? void 0,
|
|
2842
|
+
[],
|
|
2843
|
+
extractGoParams(node)
|
|
2844
|
+
);
|
|
2845
|
+
if (recvType) {
|
|
2846
|
+
pendingMethods.push({ receiverType: recvType, symbol: sym });
|
|
2847
|
+
} else {
|
|
2848
|
+
symbols.push(sym);
|
|
2849
|
+
}
|
|
2850
|
+
break;
|
|
2851
|
+
}
|
|
2852
|
+
case "type_declaration":
|
|
2853
|
+
symbols.push(...extractTypeDeclaration(node, void 0));
|
|
2854
|
+
break;
|
|
2855
|
+
case "var_declaration":
|
|
2856
|
+
case "const_declaration":
|
|
2857
|
+
symbols.push(...extractValueDeclaration(node, void 0));
|
|
2858
|
+
break;
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
return { symbols, pendingMethods };
|
|
2862
|
+
}
|
|
2863
|
+
function attachMethods(symbols, pending) {
|
|
2864
|
+
if (pending.length === 0) return symbols;
|
|
2865
|
+
const byName = /* @__PURE__ */ new Map();
|
|
2866
|
+
for (const s of symbols) {
|
|
2867
|
+
if (s.kind === "class" || s.kind === "interface") byName.set(s.name, s);
|
|
2868
|
+
}
|
|
2869
|
+
const orphans = [];
|
|
2870
|
+
for (const m of pending) {
|
|
2871
|
+
const host = byName.get(m.receiverType);
|
|
2872
|
+
if (host) {
|
|
2873
|
+
host.children = [...host.children, m.symbol];
|
|
2874
|
+
} else {
|
|
2875
|
+
orphans.push(m.symbol);
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
return [...symbols, ...orphans];
|
|
2879
|
+
}
|
|
2880
|
+
function stripQuotes2(s) {
|
|
2881
|
+
if (s.length >= 2 && (s[0] === '"' || s[0] === "'" || s[0] === "`") && s[s.length - 1] === s[0]) {
|
|
2882
|
+
return s.slice(1, -1);
|
|
2883
|
+
}
|
|
2884
|
+
return s;
|
|
2885
|
+
}
|
|
2886
|
+
function extractGoImports(rootNode) {
|
|
2887
|
+
const specs = [];
|
|
2888
|
+
const bindings = [];
|
|
2889
|
+
function visit(node) {
|
|
2890
|
+
if (node.type === "import_declaration") {
|
|
2891
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
2892
|
+
const c = node.namedChild(i);
|
|
2893
|
+
if (!c) continue;
|
|
2894
|
+
if (c.type === "import_spec") {
|
|
2895
|
+
processSpec(c);
|
|
2896
|
+
} else if (c.type === "import_spec_list") {
|
|
2897
|
+
for (let j = 0; j < c.namedChildCount; j++) {
|
|
2898
|
+
const sp = c.namedChild(j);
|
|
2899
|
+
if (sp?.type === "import_spec") processSpec(sp);
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
2906
|
+
const child = node.namedChild(i);
|
|
2907
|
+
if (child) visit(child);
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
function processSpec(spec) {
|
|
2911
|
+
const pathNode = spec.childForFieldName("path");
|
|
2912
|
+
if (!pathNode) return;
|
|
2913
|
+
const specifier = stripQuotes2(pathNode.text);
|
|
2914
|
+
if (!specifier) return;
|
|
2915
|
+
specs.push(specifier);
|
|
2916
|
+
const nameNode = spec.childForFieldName("name");
|
|
2917
|
+
let localName;
|
|
2918
|
+
if (nameNode) {
|
|
2919
|
+
localName = nameNode.text;
|
|
2920
|
+
} else {
|
|
2921
|
+
const segs = specifier.split("/");
|
|
2922
|
+
localName = segs[segs.length - 1] || specifier;
|
|
2923
|
+
}
|
|
2924
|
+
bindings.push({
|
|
2925
|
+
specifier,
|
|
2926
|
+
importedName: "*",
|
|
2927
|
+
// Go imports a whole package, not specific names
|
|
2928
|
+
localName
|
|
2929
|
+
});
|
|
2930
|
+
}
|
|
2931
|
+
visit(rootNode);
|
|
2932
|
+
return { specs, bindings };
|
|
2933
|
+
}
|
|
2934
|
+
function extractGoCallSites(rootNode) {
|
|
2935
|
+
const out = [];
|
|
2936
|
+
function visit(node) {
|
|
2937
|
+
if (node.type === "call_expression") {
|
|
2938
|
+
const fn = node.childForFieldName("function");
|
|
2939
|
+
const name = calleeLeafName2(fn);
|
|
2940
|
+
if (name) {
|
|
2941
|
+
const receiverName = receiverRootName2(fn);
|
|
2942
|
+
out.push({
|
|
2943
|
+
calleeName: name,
|
|
2944
|
+
line: node.startPosition.row + 1,
|
|
2945
|
+
...receiverName ? { receiverName } : {}
|
|
2946
|
+
});
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
2950
|
+
const c = node.child(i);
|
|
2951
|
+
if (c) visit(c);
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
visit(rootNode);
|
|
2955
|
+
return out;
|
|
2956
|
+
}
|
|
2957
|
+
function calleeLeafName2(node) {
|
|
2958
|
+
if (!node) return null;
|
|
2959
|
+
if (node.type === "identifier") return node.text;
|
|
2960
|
+
if (node.type === "selector_expression") {
|
|
2961
|
+
const field = node.childForFieldName("field");
|
|
2962
|
+
return field?.text ?? null;
|
|
2963
|
+
}
|
|
2964
|
+
if (node.type === "call_expression") {
|
|
2965
|
+
return calleeLeafName2(node.childForFieldName("function"));
|
|
2966
|
+
}
|
|
2967
|
+
return null;
|
|
2968
|
+
}
|
|
2969
|
+
function receiverRootName2(node) {
|
|
2970
|
+
if (!node || node.type !== "selector_expression") return void 0;
|
|
2971
|
+
let cur = node;
|
|
2972
|
+
while (cur) {
|
|
2973
|
+
if (cur.type === "identifier") return cur.text;
|
|
2974
|
+
if (cur.type === "selector_expression") {
|
|
2975
|
+
cur = cur.childForFieldName("operand");
|
|
2976
|
+
continue;
|
|
2977
|
+
}
|
|
2978
|
+
return void 0;
|
|
2979
|
+
}
|
|
2980
|
+
return void 0;
|
|
2981
|
+
}
|
|
2982
|
+
async function readModulePath(cwd) {
|
|
2983
|
+
try {
|
|
2984
|
+
const text = await fs2.readFile(path4.join(cwd, "go.mod"), "utf8");
|
|
2985
|
+
const m = /^\s*module\s+(\S+)/m.exec(text);
|
|
2986
|
+
return m ? m[1].trim() : null;
|
|
2987
|
+
} catch {
|
|
2988
|
+
return null;
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
function bucketGoFilesByDir(fileSet) {
|
|
2992
|
+
const out = /* @__PURE__ */ new Map();
|
|
2993
|
+
for (const f of fileSet) {
|
|
2994
|
+
if (!f.endsWith(".go")) continue;
|
|
2995
|
+
const dir = path4.dirname(f);
|
|
2996
|
+
const list = out.get(dir);
|
|
2997
|
+
if (list) list.push(f);
|
|
2998
|
+
else out.set(dir, [f]);
|
|
2999
|
+
}
|
|
3000
|
+
return out;
|
|
3001
|
+
}
|
|
3002
|
+
var goHandler = {
|
|
3003
|
+
grammarId: "go",
|
|
3004
|
+
extensions: [".go"],
|
|
3005
|
+
extractSymbols(rootNode, _source) {
|
|
3006
|
+
const out = [];
|
|
3007
|
+
const header = extractGoImportHeader(rootNode);
|
|
3008
|
+
if (header) out.push(header);
|
|
3009
|
+
const { symbols, pendingMethods } = extractTopLevel(rootNode);
|
|
3010
|
+
out.push(...attachMethods(symbols, pendingMethods));
|
|
3011
|
+
out.push(...computeFillerBlocks(rootNode, out));
|
|
3012
|
+
return out;
|
|
3013
|
+
},
|
|
3014
|
+
extractImports(rootNode) {
|
|
3015
|
+
return extractGoImports(rootNode);
|
|
3016
|
+
},
|
|
3017
|
+
extractCallSites(rootNode, _symbols) {
|
|
3018
|
+
return extractGoCallSites(rootNode);
|
|
3019
|
+
},
|
|
3020
|
+
// -------- T3: call graph --------
|
|
3021
|
+
async buildProjectContext(cwd, fileSet) {
|
|
3022
|
+
const modulePath = await readModulePath(cwd);
|
|
3023
|
+
const dirToGoFiles = bucketGoFilesByDir(fileSet);
|
|
3024
|
+
const ctx = { cwd, modulePath, dirToGoFiles };
|
|
3025
|
+
return ctx;
|
|
3026
|
+
},
|
|
3027
|
+
resolveSpecifier(spec, _fromFilePath, ctx, _fileSet) {
|
|
3028
|
+
const c = ctx;
|
|
3029
|
+
if (!c.modulePath) return null;
|
|
3030
|
+
if (spec === c.modulePath) {
|
|
3031
|
+
const files = c.dirToGoFiles.get(".");
|
|
3032
|
+
return files?.[0] ?? null;
|
|
3033
|
+
}
|
|
3034
|
+
if (spec.startsWith(c.modulePath + "/")) {
|
|
3035
|
+
const relDir = spec.slice(c.modulePath.length + 1);
|
|
3036
|
+
const files = c.dirToGoFiles.get(relDir);
|
|
3037
|
+
return files?.[0] ?? null;
|
|
3038
|
+
}
|
|
3039
|
+
return null;
|
|
3040
|
+
},
|
|
3041
|
+
resolveCall(call, from, fromFile, allFiles, ctx) {
|
|
3042
|
+
const c = ctx;
|
|
3043
|
+
const fromDir = path4.dirname(fromFile.path);
|
|
3044
|
+
const samePackageFiles = c.dirToGoFiles.get(fromDir) ?? [fromFile.path];
|
|
3045
|
+
if (call.receiverName) {
|
|
3046
|
+
const recvBinding = fromFile.bindingsByLocalName.get(call.receiverName);
|
|
3047
|
+
if (recvBinding) {
|
|
3048
|
+
const recvFilePath = fromFile.resolvedImports.get(recvBinding.specifier);
|
|
3049
|
+
if (!recvFilePath) {
|
|
3050
|
+
return [
|
|
3051
|
+
{
|
|
3052
|
+
kind: "external",
|
|
3053
|
+
name: call.calleeName,
|
|
3054
|
+
packageSpec: recvBinding.specifier
|
|
3055
|
+
}
|
|
3056
|
+
];
|
|
3057
|
+
}
|
|
3058
|
+
const targetDir = path4.dirname(recvFilePath);
|
|
3059
|
+
const dirFiles = c.dirToGoFiles.get(targetDir) ?? [];
|
|
3060
|
+
for (const fp of dirFiles) {
|
|
3061
|
+
const tf = allFiles.get(fp);
|
|
3062
|
+
if (!tf) continue;
|
|
3063
|
+
const candidates = tf.symbolsByName.get(call.calleeName);
|
|
3064
|
+
if (!candidates) continue;
|
|
3065
|
+
let sym;
|
|
3066
|
+
for (const s of candidates) {
|
|
3067
|
+
if (s.qualifiedName.includes(">")) continue;
|
|
3068
|
+
if (!isCallableKind(s.kind)) continue;
|
|
3069
|
+
sym = s;
|
|
3070
|
+
break;
|
|
3071
|
+
}
|
|
3072
|
+
if (sym) {
|
|
3073
|
+
return [
|
|
3074
|
+
{
|
|
3075
|
+
kind: "symbol",
|
|
3076
|
+
addr: {
|
|
3077
|
+
filePath: sym.filePath,
|
|
3078
|
+
qualifiedName: sym.qualifiedName
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
];
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
return [
|
|
3085
|
+
{
|
|
3086
|
+
kind: "external",
|
|
3087
|
+
name: call.calleeName,
|
|
3088
|
+
packageSpec: recvBinding.specifier
|
|
3089
|
+
}
|
|
3090
|
+
];
|
|
3091
|
+
}
|
|
3092
|
+
const methodQname = `${call.receiverName}>${call.calleeName}`;
|
|
3093
|
+
for (const fp of samePackageFiles) {
|
|
3094
|
+
const tf = allFiles.get(fp);
|
|
3095
|
+
if (!tf) continue;
|
|
3096
|
+
const sym = tf.symbolsByQname.get(methodQname);
|
|
3097
|
+
if (sym && isCallableKind(sym.kind)) {
|
|
3098
|
+
return [
|
|
3099
|
+
{
|
|
3100
|
+
kind: "symbol",
|
|
3101
|
+
addr: {
|
|
3102
|
+
filePath: sym.filePath,
|
|
3103
|
+
qualifiedName: sym.qualifiedName
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
];
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
return [
|
|
3110
|
+
{
|
|
3111
|
+
kind: "method-unresolved",
|
|
3112
|
+
receiverName: call.receiverName,
|
|
3113
|
+
methodName: call.calleeName
|
|
3114
|
+
}
|
|
3115
|
+
];
|
|
3116
|
+
}
|
|
3117
|
+
const out = [];
|
|
3118
|
+
for (const fp of samePackageFiles) {
|
|
3119
|
+
const tf = allFiles.get(fp);
|
|
3120
|
+
if (!tf) continue;
|
|
3121
|
+
const candidates = tf.symbolsByName.get(call.calleeName);
|
|
3122
|
+
if (!candidates) continue;
|
|
3123
|
+
for (const s of candidates) {
|
|
3124
|
+
if (s.qualifiedName === from.qualifiedName) continue;
|
|
3125
|
+
if (s.qualifiedName.includes(">")) continue;
|
|
3126
|
+
if (!isCallableKind(s.kind)) continue;
|
|
3127
|
+
out.push({
|
|
3128
|
+
kind: "symbol",
|
|
3129
|
+
addr: { filePath: s.filePath, qualifiedName: s.qualifiedName }
|
|
3130
|
+
});
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
return out;
|
|
3134
|
+
},
|
|
3135
|
+
moduleForFile(filePath, ctx) {
|
|
3136
|
+
const c = ctx;
|
|
3137
|
+
const dir = path4.dirname(filePath);
|
|
3138
|
+
if (!c?.modulePath) return dir;
|
|
3139
|
+
return dir === "." ? c.modulePath : `${c.modulePath}/${dir}`;
|
|
3140
|
+
}
|
|
3141
|
+
};
|
|
3142
|
+
function isCallableKind(k) {
|
|
3143
|
+
return k === "function" || k === "class" || k === "method";
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
// packages/feature/explorer/src/server/codeMap/handlers/rust.ts
|
|
3147
|
+
import { promises as fs3 } from "fs";
|
|
3148
|
+
import path5 from "path";
|
|
3149
|
+
function qualify3(parent, name) {
|
|
3150
|
+
return parent ? `${parent}>${name}` : name;
|
|
3151
|
+
}
|
|
3152
|
+
function makeSymbol3(node, name, kind, parentQname, children = [], params) {
|
|
3153
|
+
return {
|
|
3154
|
+
qualifiedName: qualify3(parentQname, name),
|
|
3155
|
+
name,
|
|
3156
|
+
kind,
|
|
3157
|
+
startLine: node.startPosition.row + 1,
|
|
3158
|
+
endLine: node.endPosition.row + 1,
|
|
3159
|
+
contentHash: hashText(normalizeForHash(node.text)),
|
|
3160
|
+
children,
|
|
3161
|
+
params
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
3164
|
+
function extractRustParams(fnNode) {
|
|
3165
|
+
const params = fnNode.childForFieldName("parameters");
|
|
3166
|
+
if (!params) return void 0;
|
|
3167
|
+
const out = [];
|
|
3168
|
+
for (let i = 0; i < params.namedChildCount; i++) {
|
|
3169
|
+
const p = params.namedChild(i);
|
|
3170
|
+
if (!p) continue;
|
|
3171
|
+
if (p.type === "self_parameter") {
|
|
3172
|
+
out.push(p.text);
|
|
3173
|
+
} else if (p.type === "parameter") {
|
|
3174
|
+
const pat = p.childForFieldName("pattern");
|
|
3175
|
+
if (pat) {
|
|
3176
|
+
out.push(pat.text);
|
|
3177
|
+
} else {
|
|
3178
|
+
out.push("_");
|
|
3179
|
+
}
|
|
3180
|
+
} else if (p.type === "variadic_parameter") {
|
|
3181
|
+
out.push("...");
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
return out;
|
|
3185
|
+
}
|
|
3186
|
+
function readImplTargetType(implNode) {
|
|
3187
|
+
const t = implNode.childForFieldName("type");
|
|
3188
|
+
if (!t) return null;
|
|
3189
|
+
return readRustTypeName(t);
|
|
3190
|
+
}
|
|
3191
|
+
function readRustTypeName(t) {
|
|
3192
|
+
if (t.type === "type_identifier") return t.text;
|
|
3193
|
+
if (t.type === "generic_type") {
|
|
3194
|
+
const base = t.childForFieldName("type");
|
|
3195
|
+
if (base) return readRustTypeName(base);
|
|
3196
|
+
}
|
|
3197
|
+
if (t.type === "reference_type") {
|
|
3198
|
+
for (let i = 0; i < t.namedChildCount; i++) {
|
|
3199
|
+
const inner = t.namedChild(i);
|
|
3200
|
+
if (inner) {
|
|
3201
|
+
const r = readRustTypeName(inner);
|
|
3202
|
+
if (r) return r;
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
if (t.type === "scoped_type_identifier") {
|
|
3207
|
+
const name = t.childForFieldName("name");
|
|
3208
|
+
if (name?.type === "type_identifier") return name.text;
|
|
3209
|
+
}
|
|
3210
|
+
return null;
|
|
3211
|
+
}
|
|
3212
|
+
function extractImplMembers(impl, parentQname) {
|
|
3213
|
+
const body = impl.childForFieldName("body");
|
|
3214
|
+
if (!body) return [];
|
|
3215
|
+
const out = [];
|
|
3216
|
+
for (let i = 0; i < body.namedChildCount; i++) {
|
|
3217
|
+
const m = body.namedChild(i);
|
|
3218
|
+
if (!m) continue;
|
|
3219
|
+
if (m.type === "function_item") {
|
|
3220
|
+
const nameNode = m.childForFieldName("name");
|
|
3221
|
+
if (!nameNode) continue;
|
|
3222
|
+
out.push(
|
|
3223
|
+
makeSymbol3(
|
|
3224
|
+
m,
|
|
3225
|
+
nameNode.text,
|
|
3226
|
+
"method",
|
|
3227
|
+
parentQname,
|
|
3228
|
+
[],
|
|
3229
|
+
extractRustParams(m)
|
|
3230
|
+
)
|
|
3231
|
+
);
|
|
3232
|
+
} else if (m.type === "function_signature_item") {
|
|
3233
|
+
const nameNode = m.childForFieldName("name");
|
|
3234
|
+
if (!nameNode) continue;
|
|
3235
|
+
out.push(
|
|
3236
|
+
makeSymbol3(
|
|
3237
|
+
m,
|
|
3238
|
+
nameNode.text,
|
|
3239
|
+
"method",
|
|
3240
|
+
parentQname,
|
|
3241
|
+
[],
|
|
3242
|
+
extractRustParams(m)
|
|
3243
|
+
)
|
|
3244
|
+
);
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
return out;
|
|
3248
|
+
}
|
|
3249
|
+
function extractTraitMembers(trait, parentQname) {
|
|
3250
|
+
const body = trait.childForFieldName("body");
|
|
3251
|
+
if (!body) return [];
|
|
3252
|
+
const out = [];
|
|
3253
|
+
for (let i = 0; i < body.namedChildCount; i++) {
|
|
3254
|
+
const m = body.namedChild(i);
|
|
3255
|
+
if (!m) continue;
|
|
3256
|
+
if (m.type === "function_item" || m.type === "function_signature_item") {
|
|
3257
|
+
const nameNode = m.childForFieldName("name");
|
|
3258
|
+
if (!nameNode) continue;
|
|
3259
|
+
out.push(
|
|
3260
|
+
makeSymbol3(
|
|
3261
|
+
m,
|
|
3262
|
+
nameNode.text,
|
|
3263
|
+
"method",
|
|
3264
|
+
parentQname,
|
|
3265
|
+
[],
|
|
3266
|
+
extractRustParams(m)
|
|
3267
|
+
)
|
|
3268
|
+
);
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
return out;
|
|
3272
|
+
}
|
|
3273
|
+
function extractRustImportHeader(rootNode) {
|
|
3274
|
+
const headerNodes = [];
|
|
3275
|
+
let firstLine = -1;
|
|
3276
|
+
let lastLine = -1;
|
|
3277
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
3278
|
+
const c = rootNode.namedChild(i);
|
|
3279
|
+
if (!c) continue;
|
|
3280
|
+
if (c.type === "use_declaration" || c.type === "extern_crate_declaration") {
|
|
3281
|
+
headerNodes.push(c);
|
|
3282
|
+
if (firstLine < 0) firstLine = c.startPosition.row + 1;
|
|
3283
|
+
lastLine = c.endPosition.row + 1;
|
|
3284
|
+
} else if (firstLine >= 0) {
|
|
3285
|
+
break;
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
if (firstLine < 0) return null;
|
|
3289
|
+
const text = headerNodes.map((n) => n.text).join("\n");
|
|
3290
|
+
return {
|
|
3291
|
+
qualifiedName: "__imports__",
|
|
3292
|
+
name: "imports",
|
|
3293
|
+
kind: "unknown",
|
|
3294
|
+
startLine: firstLine,
|
|
3295
|
+
endLine: lastLine,
|
|
3296
|
+
contentHash: hashText(normalizeForHash(text)),
|
|
3297
|
+
children: []
|
|
3298
|
+
};
|
|
3299
|
+
}
|
|
3300
|
+
function extractTopLevel2(rootNode) {
|
|
3301
|
+
const symbols = [];
|
|
3302
|
+
const pendingImpls = [];
|
|
3303
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
3304
|
+
const node = rootNode.namedChild(i);
|
|
3305
|
+
if (!node) continue;
|
|
3306
|
+
switch (node.type) {
|
|
3307
|
+
case "function_item": {
|
|
3308
|
+
const nameNode = node.childForFieldName("name");
|
|
3309
|
+
if (!nameNode) break;
|
|
3310
|
+
symbols.push(
|
|
3311
|
+
makeSymbol3(
|
|
3312
|
+
node,
|
|
3313
|
+
nameNode.text,
|
|
3314
|
+
"function",
|
|
3315
|
+
void 0,
|
|
3316
|
+
[],
|
|
3317
|
+
extractRustParams(node)
|
|
3318
|
+
)
|
|
3319
|
+
);
|
|
3320
|
+
break;
|
|
3321
|
+
}
|
|
3322
|
+
case "struct_item":
|
|
3323
|
+
case "union_item": {
|
|
3324
|
+
const nameNode = node.childForFieldName("name");
|
|
3325
|
+
if (!nameNode) break;
|
|
3326
|
+
symbols.push(makeSymbol3(node, nameNode.text, "class", void 0));
|
|
3327
|
+
break;
|
|
3328
|
+
}
|
|
3329
|
+
case "enum_item": {
|
|
3330
|
+
const nameNode = node.childForFieldName("name");
|
|
3331
|
+
if (!nameNode) break;
|
|
3332
|
+
symbols.push(makeSymbol3(node, nameNode.text, "enum", void 0));
|
|
3333
|
+
break;
|
|
3334
|
+
}
|
|
3335
|
+
case "trait_item": {
|
|
3336
|
+
const nameNode = node.childForFieldName("name");
|
|
3337
|
+
if (!nameNode) break;
|
|
3338
|
+
const qname = nameNode.text;
|
|
3339
|
+
const members = extractTraitMembers(node, qname);
|
|
3340
|
+
symbols.push(
|
|
3341
|
+
makeSymbol3(node, nameNode.text, "interface", void 0, members)
|
|
3342
|
+
);
|
|
3343
|
+
break;
|
|
3344
|
+
}
|
|
3345
|
+
case "impl_item": {
|
|
3346
|
+
const target = readImplTargetType(node);
|
|
3347
|
+
if (!target) break;
|
|
3348
|
+
const methods = extractImplMembers(node, target);
|
|
3349
|
+
if (methods.length > 0) {
|
|
3350
|
+
pendingImpls.push({ targetType: target, methods });
|
|
3351
|
+
}
|
|
3352
|
+
break;
|
|
3353
|
+
}
|
|
3354
|
+
case "const_item":
|
|
3355
|
+
case "static_item": {
|
|
3356
|
+
const nameNode = node.childForFieldName("name");
|
|
3357
|
+
if (!nameNode) break;
|
|
3358
|
+
symbols.push(makeSymbol3(node, nameNode.text, "const", void 0));
|
|
3359
|
+
break;
|
|
3360
|
+
}
|
|
3361
|
+
case "type_item": {
|
|
3362
|
+
const nameNode = node.childForFieldName("name");
|
|
3363
|
+
if (!nameNode) break;
|
|
3364
|
+
symbols.push(makeSymbol3(node, nameNode.text, "type", void 0));
|
|
3365
|
+
break;
|
|
3366
|
+
}
|
|
3367
|
+
case "mod_item": {
|
|
3368
|
+
const nameNode = node.childForFieldName("name");
|
|
3369
|
+
const body = node.childForFieldName("body");
|
|
3370
|
+
if (!nameNode || !body) {
|
|
3371
|
+
break;
|
|
3372
|
+
}
|
|
3373
|
+
symbols.push(makeSymbol3(node, nameNode.text, "class", void 0));
|
|
3374
|
+
break;
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
return { symbols, pendingImpls };
|
|
3379
|
+
}
|
|
3380
|
+
function attachImplMethods(symbols, pending) {
|
|
3381
|
+
if (pending.length === 0) return symbols;
|
|
3382
|
+
const byName = /* @__PURE__ */ new Map();
|
|
3383
|
+
for (const s of symbols) {
|
|
3384
|
+
if (s.kind === "class" || s.kind === "enum" || s.kind === "interface") {
|
|
3385
|
+
byName.set(s.name, s);
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
const orphans = [];
|
|
3389
|
+
for (const impl of pending) {
|
|
3390
|
+
const host = byName.get(impl.targetType);
|
|
3391
|
+
if (host) {
|
|
3392
|
+
host.children = [...host.children, ...impl.methods];
|
|
3393
|
+
} else {
|
|
3394
|
+
orphans.push(...impl.methods);
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
return [...symbols, ...orphans];
|
|
3398
|
+
}
|
|
3399
|
+
function extractRustImports(rootNode) {
|
|
3400
|
+
const specs = [];
|
|
3401
|
+
const bindings = [];
|
|
3402
|
+
function walkUse(useNode) {
|
|
3403
|
+
for (let i = 0; i < useNode.namedChildCount; i++) {
|
|
3404
|
+
const c = useNode.namedChild(i);
|
|
3405
|
+
if (c) processUseTree(c, "");
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
function processUseTree(node, prefix) {
|
|
3409
|
+
switch (node.type) {
|
|
3410
|
+
case "use_as_clause": {
|
|
3411
|
+
const pathNode = node.childForFieldName("path");
|
|
3412
|
+
const aliasNode = node.childForFieldName("alias");
|
|
3413
|
+
if (pathNode && aliasNode) {
|
|
3414
|
+
const fullPath = joinPath(prefix, pathToString(pathNode));
|
|
3415
|
+
specs.push(fullPath);
|
|
3416
|
+
bindings.push({
|
|
3417
|
+
specifier: fullPath,
|
|
3418
|
+
importedName: leafOf(fullPath),
|
|
3419
|
+
localName: aliasNode.text
|
|
3420
|
+
});
|
|
3421
|
+
}
|
|
3422
|
+
break;
|
|
3423
|
+
}
|
|
3424
|
+
case "use_list": {
|
|
3425
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
3426
|
+
const inner = node.namedChild(i);
|
|
3427
|
+
if (inner) processUseTree(inner, prefix);
|
|
3428
|
+
}
|
|
3429
|
+
break;
|
|
3430
|
+
}
|
|
3431
|
+
case "scoped_use_list": {
|
|
3432
|
+
const pathNode = node.childForFieldName("path");
|
|
3433
|
+
const listNode = node.childForFieldName("list");
|
|
3434
|
+
const newPrefix = pathNode ? joinPath(prefix, pathToString(pathNode)) : prefix;
|
|
3435
|
+
if (listNode) {
|
|
3436
|
+
for (let i = 0; i < listNode.namedChildCount; i++) {
|
|
3437
|
+
const inner = listNode.namedChild(i);
|
|
3438
|
+
if (inner) processUseTree(inner, newPrefix);
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
break;
|
|
3442
|
+
}
|
|
3443
|
+
case "use_wildcard": {
|
|
3444
|
+
const pathNode = node.childForFieldName("path");
|
|
3445
|
+
const fullPath = pathNode ? joinPath(prefix, pathToString(pathNode)) : prefix;
|
|
3446
|
+
if (fullPath) {
|
|
3447
|
+
specs.push(fullPath);
|
|
3448
|
+
bindings.push({
|
|
3449
|
+
specifier: fullPath,
|
|
3450
|
+
importedName: "*",
|
|
3451
|
+
localName: "*"
|
|
3452
|
+
});
|
|
3453
|
+
}
|
|
3454
|
+
break;
|
|
3455
|
+
}
|
|
3456
|
+
case "identifier":
|
|
3457
|
+
case "self":
|
|
3458
|
+
case "super":
|
|
3459
|
+
case "crate":
|
|
3460
|
+
case "scoped_identifier": {
|
|
3461
|
+
const leaf = pathToString(node);
|
|
3462
|
+
const fullPath = joinPath(prefix, leaf);
|
|
3463
|
+
if (fullPath) {
|
|
3464
|
+
specs.push(fullPath);
|
|
3465
|
+
bindings.push({
|
|
3466
|
+
specifier: fullPath,
|
|
3467
|
+
importedName: leafOf(fullPath),
|
|
3468
|
+
localName: leafOf(fullPath)
|
|
3469
|
+
});
|
|
3470
|
+
}
|
|
3471
|
+
break;
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
function pathToString(node) {
|
|
3476
|
+
if (node.type === "identifier" || node.type === "crate" || node.type === "self" || node.type === "super") {
|
|
3477
|
+
return node.text;
|
|
3478
|
+
}
|
|
3479
|
+
if (node.type === "scoped_identifier") {
|
|
3480
|
+
const path7 = node.childForFieldName("path");
|
|
3481
|
+
const name = node.childForFieldName("name");
|
|
3482
|
+
const left = path7 ? pathToString(path7) : "";
|
|
3483
|
+
const right = name?.text ?? "";
|
|
3484
|
+
return left ? `${left}::${right}` : right;
|
|
3485
|
+
}
|
|
3486
|
+
return node.text;
|
|
3487
|
+
}
|
|
3488
|
+
function joinPath(prefix, suffix) {
|
|
3489
|
+
if (!prefix) return suffix;
|
|
3490
|
+
if (!suffix) return prefix;
|
|
3491
|
+
return `${prefix}::${suffix}`;
|
|
3492
|
+
}
|
|
3493
|
+
function leafOf(p) {
|
|
3494
|
+
const parts = p.split("::");
|
|
3495
|
+
return parts[parts.length - 1] ?? p;
|
|
3496
|
+
}
|
|
3497
|
+
function visit(node) {
|
|
3498
|
+
if (node.type === "use_declaration") {
|
|
3499
|
+
walkUse(node);
|
|
3500
|
+
return;
|
|
3501
|
+
}
|
|
3502
|
+
if (node.type === "extern_crate_declaration") {
|
|
3503
|
+
const nameNode = node.childForFieldName("name");
|
|
3504
|
+
if (nameNode) {
|
|
3505
|
+
specs.push(nameNode.text);
|
|
3506
|
+
bindings.push({
|
|
3507
|
+
specifier: nameNode.text,
|
|
3508
|
+
importedName: "*",
|
|
3509
|
+
localName: nameNode.text
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
return;
|
|
3513
|
+
}
|
|
3514
|
+
if (node.type === "mod_item") {
|
|
3515
|
+
const body = node.childForFieldName("body");
|
|
3516
|
+
const nameNode = node.childForFieldName("name");
|
|
3517
|
+
if (!body && nameNode) {
|
|
3518
|
+
specs.push(nameNode.text);
|
|
3519
|
+
}
|
|
3520
|
+
return;
|
|
3521
|
+
}
|
|
3522
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
3523
|
+
const c = node.namedChild(i);
|
|
3524
|
+
if (c) visit(c);
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
visit(rootNode);
|
|
3528
|
+
return { specs, bindings };
|
|
3529
|
+
}
|
|
3530
|
+
function extractRustCallSites(rootNode) {
|
|
3531
|
+
const out = [];
|
|
3532
|
+
function visit(node) {
|
|
3533
|
+
if (node.type === "call_expression") {
|
|
3534
|
+
const fn = node.childForFieldName("function");
|
|
3535
|
+
const name = calleeLeafName3(fn);
|
|
3536
|
+
if (name) {
|
|
3537
|
+
const receiverName = receiverRootName3(fn);
|
|
3538
|
+
out.push({
|
|
3539
|
+
calleeName: name,
|
|
3540
|
+
line: node.startPosition.row + 1,
|
|
3541
|
+
...receiverName ? { receiverName } : {}
|
|
3542
|
+
});
|
|
3543
|
+
}
|
|
3544
|
+
} else if (node.type === "method_call_expression") {
|
|
3545
|
+
const methodNode = node.childForFieldName("method");
|
|
3546
|
+
const receiverNode = node.childForFieldName("value");
|
|
3547
|
+
if (methodNode) {
|
|
3548
|
+
const receiverName = receiverNode?.type === "identifier" ? receiverNode.text : void 0;
|
|
3549
|
+
out.push({
|
|
3550
|
+
calleeName: methodNode.text,
|
|
3551
|
+
line: node.startPosition.row + 1,
|
|
3552
|
+
...receiverName ? { receiverName } : {}
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
3557
|
+
const c = node.child(i);
|
|
3558
|
+
if (c) visit(c);
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
visit(rootNode);
|
|
3562
|
+
return out;
|
|
3563
|
+
}
|
|
3564
|
+
function calleeLeafName3(node) {
|
|
3565
|
+
if (!node) return null;
|
|
3566
|
+
if (node.type === "identifier") return node.text;
|
|
3567
|
+
if (node.type === "scoped_identifier") {
|
|
3568
|
+
const name = node.childForFieldName("name");
|
|
3569
|
+
return name?.text ?? null;
|
|
3570
|
+
}
|
|
3571
|
+
if (node.type === "field_expression") {
|
|
3572
|
+
const field = node.childForFieldName("field");
|
|
3573
|
+
return field?.text ?? null;
|
|
3574
|
+
}
|
|
3575
|
+
return null;
|
|
3576
|
+
}
|
|
3577
|
+
function receiverRootName3(node) {
|
|
3578
|
+
if (!node) return void 0;
|
|
3579
|
+
if (node.type === "scoped_identifier") {
|
|
3580
|
+
let cur = node;
|
|
3581
|
+
while (cur) {
|
|
3582
|
+
if (cur.type === "identifier") return cur.text;
|
|
3583
|
+
if (cur.type === "scoped_identifier") {
|
|
3584
|
+
cur = cur.childForFieldName("path");
|
|
3585
|
+
continue;
|
|
3586
|
+
}
|
|
3587
|
+
break;
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
if (node.type === "field_expression") {
|
|
3591
|
+
const value = node.childForFieldName("value");
|
|
3592
|
+
if (value?.type === "identifier") return value.text;
|
|
3593
|
+
}
|
|
3594
|
+
return void 0;
|
|
3595
|
+
}
|
|
3596
|
+
function findRustEntryFiles(fileSet) {
|
|
3597
|
+
const out = [];
|
|
3598
|
+
for (const f of fileSet) {
|
|
3599
|
+
if (f === "src/lib.rs" || f === "src/main.rs" || f.endsWith("/src/lib.rs") || f.endsWith("/src/main.rs") || /^src\/bin\/[^/]+\.rs$/.test(f) || /\/src\/bin\/[^/]+\.rs$/.test(f)) {
|
|
3600
|
+
out.push(f);
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
return out;
|
|
3604
|
+
}
|
|
3605
|
+
function stripRustCommentsAndStrings(source) {
|
|
3606
|
+
return source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").replace(/"(?:\\.|[^"\\\n])*"/g, '""');
|
|
3607
|
+
}
|
|
3608
|
+
function findFileModDeclarations(source) {
|
|
3609
|
+
const cleaned = stripRustCommentsAndStrings(source);
|
|
3610
|
+
const out = [];
|
|
3611
|
+
const re = /\b(?:pub(?:\s*\([^)]*\))?\s+)?mod\s+(\w+)\s*;/g;
|
|
3612
|
+
let m;
|
|
3613
|
+
while ((m = re.exec(cleaned)) !== null) {
|
|
3614
|
+
out.push(m[1]);
|
|
3615
|
+
}
|
|
3616
|
+
return out;
|
|
3617
|
+
}
|
|
3618
|
+
async function buildModTree(cwd, fileSet) {
|
|
3619
|
+
const modTree = /* @__PURE__ */ new Map();
|
|
3620
|
+
const fileToMod = /* @__PURE__ */ new Map();
|
|
3621
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3622
|
+
async function walk(modPath, filePath) {
|
|
3623
|
+
if (visited.has(filePath)) return;
|
|
3624
|
+
visited.add(filePath);
|
|
3625
|
+
modTree.set(modPath, filePath);
|
|
3626
|
+
fileToMod.set(filePath, modPath);
|
|
3627
|
+
let source;
|
|
3628
|
+
try {
|
|
3629
|
+
source = await fs3.readFile(path5.join(cwd, filePath), "utf8");
|
|
3630
|
+
} catch {
|
|
3631
|
+
return;
|
|
3632
|
+
}
|
|
3633
|
+
const childMods = findFileModDeclarations(source);
|
|
3634
|
+
if (childMods.length === 0) return;
|
|
3635
|
+
const dir = path5.dirname(filePath);
|
|
3636
|
+
const baseName = path5.basename(filePath, ".rs");
|
|
3637
|
+
const possibleSubdirs = baseName === "mod" || baseName === "lib" || baseName === "main" ? [dir] : [dir, path5.join(dir, baseName)];
|
|
3638
|
+
for (const childMod of childMods) {
|
|
3639
|
+
const childModPath = `${modPath}::${childMod}`;
|
|
3640
|
+
let childFile = null;
|
|
3641
|
+
for (const subdir of possibleSubdirs) {
|
|
3642
|
+
const candidates = [
|
|
3643
|
+
path5.join(subdir, `${childMod}.rs`),
|
|
3644
|
+
path5.join(subdir, childMod, "mod.rs")
|
|
3645
|
+
];
|
|
3646
|
+
for (const c of candidates) {
|
|
3647
|
+
const normalised = c.startsWith("./") ? c.slice(2) : c;
|
|
3648
|
+
if (fileSet.has(normalised)) {
|
|
3649
|
+
childFile = normalised;
|
|
3650
|
+
break;
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
if (childFile) break;
|
|
3654
|
+
}
|
|
3655
|
+
if (childFile) {
|
|
3656
|
+
await walk(childModPath, childFile);
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
for (const entry of findRustEntryFiles(fileSet)) {
|
|
3661
|
+
if (entry === "src/lib.rs" || entry === "src/main.rs") {
|
|
3662
|
+
await walk("crate", entry);
|
|
3663
|
+
} else if (entry.startsWith("src/bin/")) {
|
|
3664
|
+
await walk("crate", entry);
|
|
3665
|
+
} else {
|
|
3666
|
+
const parts = entry.split("/");
|
|
3667
|
+
const memberIdx = parts.indexOf("src");
|
|
3668
|
+
if (memberIdx > 0) {
|
|
3669
|
+
const memberName = parts[memberIdx - 1];
|
|
3670
|
+
await walk(memberName, entry);
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
return { modTree, fileToMod };
|
|
3675
|
+
}
|
|
3676
|
+
function resolveModPath(spec, fromModPath) {
|
|
3677
|
+
if (spec.startsWith("crate::")) return spec;
|
|
3678
|
+
if (spec === "crate") return "crate";
|
|
3679
|
+
if (spec.startsWith("self::")) {
|
|
3680
|
+
return `${fromModPath}::${spec.slice("self::".length)}`;
|
|
3681
|
+
}
|
|
3682
|
+
if (spec === "self") return fromModPath;
|
|
3683
|
+
if (spec.startsWith("super::")) {
|
|
3684
|
+
let parent = fromModPath;
|
|
3685
|
+
let rest = spec;
|
|
3686
|
+
while (rest.startsWith("super::")) {
|
|
3687
|
+
const lastSep = parent.lastIndexOf("::");
|
|
3688
|
+
if (lastSep < 0) return null;
|
|
3689
|
+
parent = parent.slice(0, lastSep);
|
|
3690
|
+
rest = rest.slice("super::".length);
|
|
3691
|
+
}
|
|
3692
|
+
if (rest === "super") {
|
|
3693
|
+
const lastSep = parent.lastIndexOf("::");
|
|
3694
|
+
return lastSep < 0 ? null : parent.slice(0, lastSep);
|
|
3695
|
+
}
|
|
3696
|
+
return rest ? `${parent}::${rest}` : parent;
|
|
3697
|
+
}
|
|
3698
|
+
return null;
|
|
3699
|
+
}
|
|
3700
|
+
var rustHandler = {
|
|
3701
|
+
grammarId: "rust",
|
|
3702
|
+
extensions: [".rs"],
|
|
3703
|
+
extractSymbols(rootNode, _source) {
|
|
3704
|
+
const out = [];
|
|
3705
|
+
const header = extractRustImportHeader(rootNode);
|
|
3706
|
+
if (header) out.push(header);
|
|
3707
|
+
const { symbols, pendingImpls } = extractTopLevel2(rootNode);
|
|
3708
|
+
out.push(...attachImplMethods(symbols, pendingImpls));
|
|
3709
|
+
out.push(...computeFillerBlocks(rootNode, out));
|
|
3710
|
+
return out;
|
|
3711
|
+
},
|
|
3712
|
+
extractImports(rootNode) {
|
|
3713
|
+
return extractRustImports(rootNode);
|
|
3714
|
+
},
|
|
3715
|
+
extractCallSites(rootNode, _symbols) {
|
|
3716
|
+
return extractRustCallSites(rootNode);
|
|
3717
|
+
},
|
|
3718
|
+
// -------- T3: call graph --------
|
|
3719
|
+
async buildProjectContext(cwd, fileSet) {
|
|
3720
|
+
const { modTree, fileToMod } = await buildModTree(cwd, fileSet);
|
|
3721
|
+
const ctx = { cwd, modTree, fileToMod };
|
|
3722
|
+
return ctx;
|
|
3723
|
+
},
|
|
3724
|
+
resolveSpecifier(spec, fromFilePath, ctx, _fileSet) {
|
|
3725
|
+
const c = ctx;
|
|
3726
|
+
const fromMod = c.fileToMod.get(fromFilePath);
|
|
3727
|
+
if (!fromMod) return null;
|
|
3728
|
+
const resolved = resolveModPath(spec, fromMod);
|
|
3729
|
+
if (!resolved) return null;
|
|
3730
|
+
if (c.modTree.has(resolved)) return c.modTree.get(resolved);
|
|
3731
|
+
const segs = resolved.split("::");
|
|
3732
|
+
while (segs.length > 1) {
|
|
3733
|
+
segs.pop();
|
|
3734
|
+
const candidate = segs.join("::");
|
|
3735
|
+
const file = c.modTree.get(candidate);
|
|
3736
|
+
if (file) return file;
|
|
3737
|
+
}
|
|
3738
|
+
return null;
|
|
3739
|
+
},
|
|
3740
|
+
resolveCall(call, from, fromFile, allFiles, _ctx) {
|
|
3741
|
+
if (call.receiverName) {
|
|
3742
|
+
const recvBinding = fromFile.bindingsByLocalName.get(call.receiverName);
|
|
3743
|
+
if (recvBinding) {
|
|
3744
|
+
const recvFilePath = fromFile.resolvedImports.get(recvBinding.specifier);
|
|
3745
|
+
if (!recvFilePath) {
|
|
3746
|
+
return [
|
|
3747
|
+
{
|
|
3748
|
+
kind: "external",
|
|
3749
|
+
name: call.calleeName,
|
|
3750
|
+
packageSpec: recvBinding.specifier
|
|
3751
|
+
}
|
|
3752
|
+
];
|
|
3753
|
+
}
|
|
3754
|
+
const targetFile2 = allFiles.get(recvFilePath);
|
|
3755
|
+
if (!targetFile2) return [];
|
|
3756
|
+
const candidates = targetFile2.symbolsByName.get(call.calleeName);
|
|
3757
|
+
if (candidates) {
|
|
3758
|
+
for (const s of candidates) {
|
|
3759
|
+
if (s.qualifiedName.includes(">")) continue;
|
|
3760
|
+
if (!isCallableKind2(s.kind)) continue;
|
|
3761
|
+
return [
|
|
3762
|
+
{
|
|
3763
|
+
kind: "symbol",
|
|
3764
|
+
addr: {
|
|
3765
|
+
filePath: s.filePath,
|
|
3766
|
+
qualifiedName: s.qualifiedName
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
];
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
const nestedQname = `${recvBinding.importedName}>${call.calleeName}`;
|
|
3773
|
+
const nested = targetFile2.symbolsByQname.get(nestedQname);
|
|
3774
|
+
if (nested && isCallableKind2(nested.kind)) {
|
|
3775
|
+
return [
|
|
3776
|
+
{
|
|
3777
|
+
kind: "symbol",
|
|
3778
|
+
addr: {
|
|
3779
|
+
filePath: nested.filePath,
|
|
3780
|
+
qualifiedName: nested.qualifiedName
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
];
|
|
3784
|
+
}
|
|
3785
|
+
return [
|
|
3786
|
+
{
|
|
3787
|
+
kind: "method-unresolved",
|
|
3788
|
+
receiverName: call.receiverName,
|
|
3789
|
+
methodName: call.calleeName
|
|
3790
|
+
}
|
|
3791
|
+
];
|
|
3792
|
+
}
|
|
3793
|
+
const directMethod = `${call.receiverName}>${call.calleeName}`;
|
|
3794
|
+
const directHit = fromFile.symbolsByQname.get(directMethod);
|
|
3795
|
+
if (directHit) {
|
|
3796
|
+
return [
|
|
3797
|
+
{
|
|
3798
|
+
kind: "symbol",
|
|
3799
|
+
addr: {
|
|
3800
|
+
filePath: directHit.filePath,
|
|
3801
|
+
qualifiedName: directHit.qualifiedName
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
];
|
|
3805
|
+
}
|
|
3806
|
+
const out = [];
|
|
3807
|
+
const allSameName = fromFile.symbolsByName.get(call.calleeName);
|
|
3808
|
+
if (allSameName) {
|
|
3809
|
+
for (const s of allSameName) {
|
|
3810
|
+
if (s.kind !== "method") continue;
|
|
3811
|
+
out.push({
|
|
3812
|
+
kind: "symbol",
|
|
3813
|
+
addr: { filePath: s.filePath, qualifiedName: s.qualifiedName }
|
|
3814
|
+
});
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
if (out.length > 0) return out;
|
|
3818
|
+
return [
|
|
3819
|
+
{
|
|
3820
|
+
kind: "method-unresolved",
|
|
3821
|
+
receiverName: call.receiverName,
|
|
3822
|
+
methodName: call.calleeName
|
|
3823
|
+
}
|
|
3824
|
+
];
|
|
3825
|
+
}
|
|
3826
|
+
const local = [];
|
|
3827
|
+
const localCandidates = fromFile.symbolsByName.get(call.calleeName);
|
|
3828
|
+
if (localCandidates) {
|
|
3829
|
+
for (const s of localCandidates) {
|
|
3830
|
+
if (s.qualifiedName === from.qualifiedName) continue;
|
|
3831
|
+
if (s.qualifiedName.includes(">")) continue;
|
|
3832
|
+
if (!isCallableKind2(s.kind)) continue;
|
|
3833
|
+
local.push({
|
|
3834
|
+
kind: "symbol",
|
|
3835
|
+
addr: { filePath: s.filePath, qualifiedName: s.qualifiedName }
|
|
3836
|
+
});
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
if (local.length > 0) return local;
|
|
3840
|
+
const binding = fromFile.bindingsByLocalName.get(call.calleeName);
|
|
3841
|
+
if (!binding) return [];
|
|
3842
|
+
const targetFile = fromFile.resolvedImports.get(binding.specifier);
|
|
3843
|
+
if (!targetFile) {
|
|
3844
|
+
return [
|
|
3845
|
+
{
|
|
3846
|
+
kind: "external",
|
|
3847
|
+
name: binding.importedName,
|
|
3848
|
+
packageSpec: binding.specifier
|
|
3849
|
+
}
|
|
3850
|
+
];
|
|
3851
|
+
}
|
|
3852
|
+
const target = allFiles.get(targetFile);
|
|
3853
|
+
if (!target) return [];
|
|
3854
|
+
const targetCandidates = target.symbolsByName.get(binding.importedName);
|
|
3855
|
+
let sym;
|
|
3856
|
+
if (targetCandidates) {
|
|
3857
|
+
for (const s of targetCandidates) {
|
|
3858
|
+
if (s.qualifiedName.includes(">")) continue;
|
|
3859
|
+
if (!isCallableKind2(s.kind)) continue;
|
|
3860
|
+
sym = s;
|
|
3861
|
+
break;
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
if (!sym) return [];
|
|
3865
|
+
return [
|
|
3866
|
+
{
|
|
3867
|
+
kind: "symbol",
|
|
3868
|
+
addr: { filePath: sym.filePath, qualifiedName: sym.qualifiedName }
|
|
3869
|
+
}
|
|
3870
|
+
];
|
|
3871
|
+
},
|
|
3872
|
+
moduleForFile(filePath, ctx) {
|
|
3873
|
+
const c = ctx;
|
|
3874
|
+
return c?.fileToMod.get(filePath) ?? path5.dirname(filePath);
|
|
3875
|
+
}
|
|
3876
|
+
};
|
|
3877
|
+
function isCallableKind2(k) {
|
|
3878
|
+
return k === "function" || k === "class" || k === "method";
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3881
|
+
// packages/feature/explorer/src/server/codeMap/handlers/index.ts
|
|
3882
|
+
registerHandler(typescriptHandler);
|
|
3883
|
+
registerHandler(tsxHandler);
|
|
3884
|
+
registerHandler(javascriptHandler);
|
|
3885
|
+
registerHandler(pythonHandler);
|
|
3886
|
+
registerHandler(goHandler);
|
|
3887
|
+
registerHandler(rustHandler);
|
|
3888
|
+
|
|
3889
|
+
// packages/feature/explorer/src/server/codeMap/projectGraph/codeIndex.ts
|
|
3890
|
+
var dirtyCwds = /* @__PURE__ */ new Set();
|
|
3891
|
+
var subscribedCwds = /* @__PURE__ */ new Set();
|
|
3892
|
+
var watcherSubscriber = null;
|
|
3893
|
+
function registerWatcherSubscriber(fn) {
|
|
3894
|
+
watcherSubscriber = fn;
|
|
3895
|
+
if (fn) {
|
|
3896
|
+
for (const cwd of subscribedCwds) {
|
|
3897
|
+
fn(cwd, () => dirtyCwds.add(cwd));
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
|
|
3902
|
+
// src/lib/codeIndexSync.ts
|
|
3903
|
+
var wired = false;
|
|
3904
|
+
function wireCodeIndexToFileWatcher() {
|
|
3905
|
+
if (wired) return;
|
|
3906
|
+
wired = true;
|
|
3907
|
+
registerWatcherSubscriber((cwd, onDirty) => {
|
|
3908
|
+
fileWatcher.subscribe(cwd, (events) => {
|
|
3909
|
+
if (events.some((e) => e.type === "file" || e.type === "git")) {
|
|
3910
|
+
onDirty();
|
|
3911
|
+
}
|
|
3912
|
+
});
|
|
3913
|
+
});
|
|
3914
|
+
}
|
|
3915
|
+
|
|
1191
3916
|
// src/lib/wsServer.ts
|
|
3917
|
+
wireCodeIndexToFileWatcher();
|
|
1192
3918
|
var g_ws = globalThis;
|
|
1193
3919
|
var globalStateClients = g_ws.__cockpitGlobalStateClients ?? (g_ws.__cockpitGlobalStateClients = /* @__PURE__ */ new Set());
|
|
1194
3920
|
function broadcastToGlobalState(msg) {
|