@lzehrung/codegraph 2.3.31 → 3.0.0
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/README.md +33 -141
- package/codegraph-skill/codegraph/SKILL.md +8 -6
- package/dist/agent/artifact.d.ts +2 -0
- package/dist/agent/artifact.d.ts.map +1 -1
- package/dist/agent/artifact.js.map +1 -1
- package/dist/agent/call-hierarchy.js +2 -4
- package/dist/agent/call-hierarchy.js.map +1 -1
- package/dist/agent/explore.d.ts +1 -1
- package/dist/agent/explore.d.ts.map +1 -1
- package/dist/agent/explore.js +3 -2
- package/dist/agent/explore.js.map +1 -1
- package/dist/agent/refactor-plan.js +2 -4
- package/dist/agent/refactor-plan.js.map +1 -1
- package/dist/agent/rename-preview.d.ts.map +1 -1
- package/dist/agent/rename-preview.js +4 -3
- package/dist/agent/rename-preview.js.map +1 -1
- package/dist/agent/search.d.ts.map +1 -1
- package/dist/agent/search.js +5 -3
- package/dist/agent/search.js.map +1 -1
- package/dist/agent/semantic-symbols.d.ts.map +1 -1
- package/dist/agent/semantic-symbols.js +2 -3
- package/dist/agent/semantic-symbols.js.map +1 -1
- package/dist/agent/session.d.ts +3 -0
- package/dist/agent/session.d.ts.map +1 -1
- package/dist/agent/session.js +10 -2
- package/dist/agent/session.js.map +1 -1
- package/dist/agent/type-hierarchy.js +2 -4
- package/dist/agent/type-hierarchy.js.map +1 -1
- package/dist/agent/workspace-symbols.d.ts.map +1 -1
- package/dist/agent/workspace-symbols.js +2 -3
- package/dist/agent/workspace-symbols.js.map +1 -1
- package/dist/agent-tools.d.ts +0 -4
- package/dist/agent-tools.d.ts.map +1 -1
- package/dist/agent-tools.js +3 -6
- package/dist/agent-tools.js.map +1 -1
- package/dist/analysis-summary.d.ts +8 -4
- package/dist/analysis-summary.d.ts.map +1 -1
- package/dist/analysis-summary.js +15 -66
- package/dist/analysis-summary.js.map +1 -1
- package/dist/bin/cli.js +51145 -41770
- package/dist/bin/query-index-worker.js +122 -82
- package/dist/cli/affected.d.ts.map +1 -1
- package/dist/cli/affected.js +4 -1
- package/dist/cli/affected.js.map +1 -1
- package/dist/cli/command-catalog.js +1 -1
- package/dist/cli/command-catalog.js.map +1 -1
- package/dist/cli/command-table.d.ts.map +1 -1
- package/dist/cli/command-table.js +9 -17
- package/dist/cli/command-table.js.map +1 -1
- package/dist/cli/context.js +10 -10
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/drift.d.ts +0 -2
- package/dist/cli/drift.d.ts.map +1 -1
- package/dist/cli/drift.js +0 -1
- package/dist/cli/drift.js.map +1 -1
- package/dist/cli/graph-delta.d.ts +0 -2
- package/dist/cli/graph-delta.d.ts.map +1 -1
- package/dist/cli/graph-delta.js +0 -4
- package/dist/cli/graph-delta.js.map +1 -1
- package/dist/cli/graph-queries.d.ts.map +1 -1
- package/dist/cli/graph-queries.js +27 -1
- package/dist/cli/graph-queries.js.map +1 -1
- package/dist/cli/graph.d.ts +0 -3
- package/dist/cli/graph.d.ts.map +1 -1
- package/dist/cli/graph.js +4 -14
- package/dist/cli/graph.js.map +1 -1
- package/dist/cli/help.d.ts +34 -34
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +9 -14
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/impact.d.ts +0 -2
- package/dist/cli/impact.d.ts.map +1 -1
- package/dist/cli/impact.js +0 -1
- package/dist/cli/impact.js.map +1 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +5 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/inspect.d.ts +0 -2
- package/dist/cli/inspect.d.ts.map +1 -1
- package/dist/cli/inspect.js +5 -8
- package/dist/cli/inspect.js.map +1 -1
- package/dist/cli/invocation-context.d.ts +0 -3
- package/dist/cli/invocation-context.d.ts.map +1 -1
- package/dist/cli/invocation-context.js +4 -16
- package/dist/cli/invocation-context.js.map +1 -1
- package/dist/cli/navigation.d.ts +0 -2
- package/dist/cli/navigation.d.ts.map +1 -1
- package/dist/cli/navigation.js +0 -1
- package/dist/cli/navigation.js.map +1 -1
- package/dist/cli/options.d.ts.map +1 -1
- package/dist/cli/options.js +4 -14
- package/dist/cli/options.js.map +1 -1
- package/dist/cli/review.d.ts +0 -2
- package/dist/cli/review.d.ts.map +1 -1
- package/dist/cli/review.js +0 -5
- package/dist/cli/review.js.map +1 -1
- package/dist/cli/root-policy.d.ts +0 -2
- package/dist/cli/root-policy.d.ts.map +1 -1
- package/dist/cli/root-policy.js +0 -8
- package/dist/cli/root-policy.js.map +1 -1
- package/dist/cli/server.d.ts.map +1 -1
- package/dist/cli/server.js +0 -2
- package/dist/cli/server.js.map +1 -1
- package/dist/drift/artifact.d.ts.map +1 -1
- package/dist/drift/artifact.js +15 -18
- package/dist/drift/artifact.js.map +1 -1
- package/dist/drift/compare.js +1 -1
- package/dist/drift/compare.js.map +1 -1
- package/dist/drift/git.d.ts.map +1 -1
- package/dist/drift/git.js +0 -1
- package/dist/drift/git.js.map +1 -1
- package/dist/drift/snapshot.d.ts.map +1 -1
- package/dist/drift/snapshot.js +5 -7
- package/dist/drift/snapshot.js.map +1 -1
- package/dist/drift/types.d.ts +2 -2
- package/dist/drift/types.d.ts.map +1 -1
- package/dist/drift/types.js.map +1 -1
- package/dist/duplicates/unit-cache.d.ts +0 -1
- package/dist/duplicates/unit-cache.d.ts.map +1 -1
- package/dist/duplicates/unit-cache.js +3 -11
- package/dist/duplicates/unit-cache.js.map +1 -1
- package/dist/duplicates/units.d.ts +5 -5
- package/dist/duplicates/units.d.ts.map +1 -1
- package/dist/duplicates/units.js +25 -88
- package/dist/duplicates/units.js.map +1 -1
- package/dist/graph-builder.d.ts +0 -6
- package/dist/graph-builder.d.ts.map +1 -1
- package/dist/graph-builder.js +6 -11
- package/dist/graph-builder.js.map +1 -1
- package/dist/graph-edge-collector.d.ts +4 -6
- package/dist/graph-edge-collector.d.ts.map +1 -1
- package/dist/graph-edge-collector.js +31 -26
- package/dist/graph-edge-collector.js.map +1 -1
- package/dist/graphs/angularjs.d.ts.map +1 -1
- package/dist/graphs/angularjs.js +2 -1
- package/dist/graphs/angularjs.js.map +1 -1
- package/dist/graphs/edge-resolution.d.ts +4 -1
- package/dist/graphs/edge-resolution.d.ts.map +1 -1
- package/dist/graphs/edge-resolution.js +24 -76
- package/dist/graphs/edge-resolution.js.map +1 -1
- package/dist/graphs/specifiers.d.ts +4 -13
- package/dist/graphs/specifiers.d.ts.map +1 -1
- package/dist/graphs/specifiers.js +80 -173
- package/dist/graphs/specifiers.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/ast.d.ts +20 -0
- package/dist/graphs/symbol-graph-detailed/ast.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/ast.js +154 -15
- package/dist/graphs/symbol-graph-detailed/ast.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts +60 -8
- package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/edge-passes.js +997 -168
- package/dist/graphs/symbol-graph-detailed/edge-passes.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/import-aliases.d.ts +2 -1
- package/dist/graphs/symbol-graph-detailed/import-aliases.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/import-aliases.js +150 -7
- package/dist/graphs/symbol-graph-detailed/import-aliases.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/member-chains.d.ts +1 -0
- package/dist/graphs/symbol-graph-detailed/member-chains.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/member-chains.js +3 -1
- package/dist/graphs/symbol-graph-detailed/member-chains.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts +141 -25
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js +1015 -166
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed.js +449 -46
- package/dist/graphs/symbol-graph-detailed.js.map +1 -1
- package/dist/graphs/symbol-graph.d.ts +2 -0
- package/dist/graphs/symbol-graph.d.ts.map +1 -1
- package/dist/graphs/symbol-graph.js +34 -16
- package/dist/graphs/symbol-graph.js.map +1 -1
- package/dist/graphs/types.d.ts +0 -4
- package/dist/graphs/types.d.ts.map +1 -1
- package/dist/graphs.d.ts +1 -1
- package/dist/graphs.d.ts.map +1 -1
- package/dist/impact/call-compatibility/providers/index.d.ts +4 -4
- package/dist/impact/call-compatibility/providers/index.d.ts.map +1 -1
- package/dist/impact/call-compatibility/providers/index.js +6 -6
- package/dist/impact/call-compatibility/providers/index.js.map +1 -1
- package/dist/impact/call-compatibility/providers/types.d.ts +2 -0
- package/dist/impact/call-compatibility/providers/types.d.ts.map +1 -1
- package/dist/impact/call-compatibility/types.d.ts +6 -0
- package/dist/impact/call-compatibility/types.d.ts.map +1 -1
- package/dist/impact/call-compatibility.d.ts.map +1 -1
- package/dist/impact/call-compatibility.js +316 -526
- package/dist/impact/call-compatibility.js.map +1 -1
- package/dist/impact/map.js +1 -0
- package/dist/impact/map.js.map +1 -1
- package/dist/impact/reference-cache.d.ts.map +1 -1
- package/dist/impact/reference-cache.js +2 -2
- package/dist/impact/reference-cache.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/indexer/ambiguous-resolution.d.ts +11 -0
- package/dist/indexer/ambiguous-resolution.d.ts.map +1 -0
- package/dist/indexer/ambiguous-resolution.js +19 -0
- package/dist/indexer/ambiguous-resolution.js.map +1 -0
- package/dist/indexer/build-cache/module-cache.d.ts +39 -1
- package/dist/indexer/build-cache/module-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache/module-cache.js +218 -21
- package/dist/indexer/build-cache/module-cache.js.map +1 -1
- package/dist/indexer/build-cache/options.d.ts +30 -44
- package/dist/indexer/build-cache/options.d.ts.map +1 -1
- package/dist/indexer/build-cache/options.js +32 -71
- package/dist/indexer/build-cache/options.js.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.d.ts +3 -3
- package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.js +164 -84
- package/dist/indexer/build-cache/project-snapshot.js.map +1 -1
- package/dist/indexer/build-cache/reports.d.ts +0 -2
- package/dist/indexer/build-cache/reports.d.ts.map +1 -1
- package/dist/indexer/build-cache/reports.js +0 -97
- package/dist/indexer/build-cache/reports.js.map +1 -1
- package/dist/indexer/build-cache/resolver-environment.d.ts.map +1 -1
- package/dist/indexer/build-cache/resolver-environment.js +32 -2
- package/dist/indexer/build-cache/resolver-environment.js.map +1 -1
- package/dist/indexer/build-cache.d.ts +2 -2
- package/dist/indexer/build-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache.js +2 -2
- package/dist/indexer/build-cache.js.map +1 -1
- package/dist/indexer/build-index.d.ts.map +1 -1
- package/dist/indexer/build-index.js +656 -71
- package/dist/indexer/build-index.js.map +1 -1
- package/dist/indexer/build-workers.d.ts.map +1 -1
- package/dist/indexer/build-workers.js +9 -9
- package/dist/indexer/build-workers.js.map +1 -1
- package/dist/indexer/call-hierarchy.js +1 -1
- package/dist/indexer/call-hierarchy.js.map +1 -1
- package/dist/indexer/callable-identity.d.ts +24 -0
- package/dist/indexer/callable-identity.d.ts.map +1 -0
- package/dist/indexer/callable-identity.js +111 -0
- package/dist/indexer/callable-identity.js.map +1 -0
- package/dist/indexer/compilation-units.d.ts +103 -0
- package/dist/indexer/compilation-units.d.ts.map +1 -0
- package/dist/indexer/compilation-units.js +607 -0
- package/dist/indexer/compilation-units.js.map +1 -0
- package/dist/indexer/cpp-callables.d.ts +25 -0
- package/dist/indexer/cpp-callables.d.ts.map +1 -0
- package/dist/indexer/cpp-callables.js +562 -0
- package/dist/indexer/cpp-callables.js.map +1 -0
- package/dist/indexer/declaration-visibility.d.ts +43 -2
- package/dist/indexer/declaration-visibility.d.ts.map +1 -1
- package/dist/indexer/declaration-visibility.js +158 -2
- package/dist/indexer/declaration-visibility.js.map +1 -1
- package/dist/indexer/expand-star-imports.d.ts +6 -1
- package/dist/indexer/expand-star-imports.d.ts.map +1 -1
- package/dist/indexer/expand-star-imports.js +131 -37
- package/dist/indexer/expand-star-imports.js.map +1 -1
- package/dist/indexer/finalize.d.ts.map +1 -1
- package/dist/indexer/finalize.js +0 -1
- package/dist/indexer/finalize.js.map +1 -1
- package/dist/indexer/import-resolution-tables.d.ts +72 -0
- package/dist/indexer/import-resolution-tables.d.ts.map +1 -0
- package/dist/indexer/import-resolution-tables.js +137 -0
- package/dist/indexer/import-resolution-tables.js.map +1 -0
- package/dist/indexer/import-types.d.ts +54 -0
- package/dist/indexer/import-types.d.ts.map +1 -1
- package/dist/indexer/import-types.js +24 -1
- package/dist/indexer/import-types.js.map +1 -1
- package/dist/indexer/imports/context.d.ts +16 -1
- package/dist/indexer/imports/context.d.ts.map +1 -1
- package/dist/indexer/imports/import-binding-tables.d.ts +13 -1
- package/dist/indexer/imports/import-binding-tables.d.ts.map +1 -1
- package/dist/indexer/imports/import-binding-tables.js +149 -30
- package/dist/indexer/imports/import-binding-tables.js.map +1 -1
- package/dist/indexer/imports/js-text-imports.js +4 -4
- package/dist/indexer/imports/js-text-imports.js.map +1 -1
- package/dist/indexer/imports/native-captures.d.ts.map +1 -1
- package/dist/indexer/imports/native-captures.js +24 -6
- package/dist/indexer/imports/native-captures.js.map +1 -1
- package/dist/indexer/imports/python.d.ts +10 -2
- package/dist/indexer/imports/python.d.ts.map +1 -1
- package/dist/indexer/imports/python.js +128 -112
- package/dist/indexer/imports/python.js.map +1 -1
- package/dist/indexer/imports/text-import-extractors.d.ts.map +1 -1
- package/dist/indexer/imports/text-import-extractors.js +68 -19
- package/dist/indexer/imports/text-import-extractors.js.map +1 -1
- package/dist/indexer/imports.d.ts +3 -4
- package/dist/indexer/imports.d.ts.map +1 -1
- package/dist/indexer/imports.js +116 -72
- package/dist/indexer/imports.js.map +1 -1
- package/dist/indexer/incremental-plan.d.ts +33 -0
- package/dist/indexer/incremental-plan.d.ts.map +1 -1
- package/dist/indexer/incremental-plan.js +203 -1
- package/dist/indexer/incremental-plan.js.map +1 -1
- package/dist/indexer/locals-and-exports.d.ts +3 -2
- package/dist/indexer/locals-and-exports.d.ts.map +1 -1
- package/dist/indexer/locals-and-exports.js +659 -78
- package/dist/indexer/locals-and-exports.js.map +1 -1
- package/dist/indexer/member-selection.d.ts +46 -0
- package/dist/indexer/member-selection.d.ts.map +1 -0
- package/dist/indexer/member-selection.js +169 -0
- package/dist/indexer/member-selection.js.map +1 -0
- package/dist/indexer/name-lookup-policies/c-family.d.ts +7 -0
- package/dist/indexer/name-lookup-policies/c-family.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/c-family.js +137 -0
- package/dist/indexer/name-lookup-policies/c-family.js.map +1 -0
- package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts +11 -0
- package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/csharp-using-static.js +136 -0
- package/dist/indexer/name-lookup-policies/csharp-using-static.js.map +1 -0
- package/dist/indexer/name-lookup-policies/implicit-self.d.ts +10 -0
- package/dist/indexer/name-lookup-policies/implicit-self.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/implicit-self.js +119 -0
- package/dist/indexer/name-lookup-policies/implicit-self.js.map +1 -0
- package/dist/indexer/name-lookup-policies/index.d.ts +3 -0
- package/dist/indexer/name-lookup-policies/index.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/index.js +132 -0
- package/dist/indexer/name-lookup-policies/index.js.map +1 -0
- package/dist/indexer/name-lookup-policies/php.d.ts +3 -0
- package/dist/indexer/name-lookup-policies/php.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/php.js +82 -0
- package/dist/indexer/name-lookup-policies/php.js.map +1 -0
- package/dist/indexer/name-resolution-types.d.ts +101 -0
- package/dist/indexer/name-resolution-types.d.ts.map +1 -0
- package/dist/indexer/name-resolution-types.js +2 -0
- package/dist/indexer/name-resolution-types.js.map +1 -0
- package/dist/indexer/name-resolution.d.ts +57 -0
- package/dist/indexer/name-resolution.d.ts.map +1 -0
- package/dist/indexer/name-resolution.js +204 -0
- package/dist/indexer/name-resolution.js.map +1 -0
- package/dist/indexer/navigation-cpp.d.ts +58 -0
- package/dist/indexer/navigation-cpp.d.ts.map +1 -0
- package/dist/indexer/navigation-cpp.js +935 -0
- package/dist/indexer/navigation-cpp.js.map +1 -0
- package/dist/indexer/navigation-goto.d.ts +115 -3
- package/dist/indexer/navigation-goto.d.ts.map +1 -1
- package/dist/indexer/navigation-goto.js +2469 -190
- package/dist/indexer/navigation-goto.js.map +1 -1
- package/dist/indexer/navigation-local.d.ts +21 -2
- package/dist/indexer/navigation-local.d.ts.map +1 -1
- package/dist/indexer/navigation-local.js +520 -63
- package/dist/indexer/navigation-local.js.map +1 -1
- package/dist/indexer/navigation-php.d.ts +66 -0
- package/dist/indexer/navigation-php.d.ts.map +1 -1
- package/dist/indexer/navigation-php.js +287 -4
- package/dist/indexer/navigation-php.js.map +1 -1
- package/dist/indexer/navigation-provenance.d.ts +1 -1
- package/dist/indexer/navigation-provenance.d.ts.map +1 -1
- package/dist/indexer/navigation-provenance.js +4 -13
- package/dist/indexer/navigation-provenance.js.map +1 -1
- package/dist/indexer/navigation-references.d.ts +73 -6
- package/dist/indexer/navigation-references.d.ts.map +1 -1
- package/dist/indexer/navigation-references.js +661 -67
- package/dist/indexer/navigation-references.js.map +1 -1
- package/dist/indexer/navigation-resolve.d.ts +46 -2
- package/dist/indexer/navigation-resolve.d.ts.map +1 -1
- package/dist/indexer/navigation-resolve.js +599 -193
- package/dist/indexer/navigation-resolve.js.map +1 -1
- package/dist/indexer/navigation.d.ts +29 -2
- package/dist/indexer/navigation.d.ts.map +1 -1
- package/dist/indexer/navigation.js +1092 -153
- package/dist/indexer/navigation.js.map +1 -1
- package/dist/indexer/parse-context.d.ts +2 -3
- package/dist/indexer/parse-context.d.ts.map +1 -1
- package/dist/indexer/parse-context.js +8 -21
- package/dist/indexer/parse-context.js.map +1 -1
- package/dist/indexer/php-namespace-symbols.d.ts +66 -0
- package/dist/indexer/php-namespace-symbols.d.ts.map +1 -0
- package/dist/indexer/php-namespace-symbols.js +342 -0
- package/dist/indexer/php-namespace-symbols.js.map +1 -0
- package/dist/indexer/reference-candidates.d.ts.map +1 -1
- package/dist/indexer/reference-candidates.js +13 -7
- package/dist/indexer/reference-candidates.js.map +1 -1
- package/dist/indexer/reference-context.d.ts +2 -0
- package/dist/indexer/reference-context.d.ts.map +1 -1
- package/dist/indexer/reference-context.js +4 -0
- package/dist/indexer/reference-context.js.map +1 -1
- package/dist/indexer/scope-nodes.d.ts +92 -13
- package/dist/indexer/scope-nodes.d.ts.map +1 -1
- package/dist/indexer/scope-nodes.js +212 -20
- package/dist/indexer/scope-nodes.js.map +1 -1
- package/dist/indexer/scope-types.d.ts +29 -1
- package/dist/indexer/scope-types.d.ts.map +1 -1
- package/dist/indexer/scope.d.ts +2 -3
- package/dist/indexer/scope.d.ts.map +1 -1
- package/dist/indexer/scope.js +968 -47
- package/dist/indexer/scope.js.map +1 -1
- package/dist/indexer/shared-owner-identity.d.ts +53 -0
- package/dist/indexer/shared-owner-identity.d.ts.map +1 -0
- package/dist/indexer/shared-owner-identity.js +460 -0
- package/dist/indexer/shared-owner-identity.js.map +1 -0
- package/dist/indexer/shared.d.ts +1 -1
- package/dist/indexer/shared.d.ts.map +1 -1
- package/dist/indexer/shared.js +1 -1
- package/dist/indexer/shared.js.map +1 -1
- package/dist/indexer/star-import-precedence.d.ts +113 -0
- package/dist/indexer/star-import-precedence.d.ts.map +1 -0
- package/dist/indexer/star-import-precedence.js +402 -0
- package/dist/indexer/star-import-precedence.js.map +1 -0
- package/dist/indexer/symbols.d.ts +3 -1
- package/dist/indexer/symbols.d.ts.map +1 -1
- package/dist/indexer/symbols.js +58 -18
- package/dist/indexer/symbols.js.map +1 -1
- package/dist/indexer/ts-callables.d.ts +42 -0
- package/dist/indexer/ts-callables.d.ts.map +1 -0
- package/dist/indexer/ts-callables.js +233 -0
- package/dist/indexer/ts-callables.js.map +1 -0
- package/dist/indexer/types.d.ts +41 -26
- package/dist/indexer/types.d.ts.map +1 -1
- package/dist/indexer/unused-exports.d.ts +13 -0
- package/dist/indexer/unused-exports.d.ts.map +1 -0
- package/dist/indexer/unused-exports.js +159 -0
- package/dist/indexer/unused-exports.js.map +1 -0
- package/dist/indexer/workspace-symbols.d.ts.map +1 -1
- package/dist/indexer/workspace-symbols.js +3 -2
- package/dist/indexer/workspace-symbols.js.map +1 -1
- package/dist/indexer.d.ts +3 -8
- package/dist/indexer.d.ts.map +1 -1
- package/dist/indexer.js +1 -1
- package/dist/indexer.js.map +1 -1
- package/dist/languages/callable-arity.d.ts +223 -0
- package/dist/languages/callable-arity.d.ts.map +1 -0
- package/dist/languages/callable-arity.js +1199 -0
- package/dist/languages/callable-arity.js.map +1 -0
- package/dist/languages/definitions/c-family.d.ts.map +1 -1
- package/dist/languages/definitions/c-family.js +30 -1
- package/dist/languages/definitions/c-family.js.map +1 -1
- package/dist/languages/definitions/c.d.ts +4 -0
- package/dist/languages/definitions/c.d.ts.map +1 -1
- package/dist/languages/definitions/c.js +19 -0
- package/dist/languages/definitions/c.js.map +1 -1
- package/dist/languages/definitions/cpp.d.ts.map +1 -1
- package/dist/languages/definitions/cpp.js +12 -0
- package/dist/languages/definitions/cpp.js.map +1 -1
- package/dist/languages/definitions/csharp.d.ts.map +1 -1
- package/dist/languages/definitions/csharp.js +2 -8
- package/dist/languages/definitions/csharp.js.map +1 -1
- package/dist/languages/definitions/go.d.ts.map +1 -1
- package/dist/languages/definitions/go.js +3 -0
- package/dist/languages/definitions/go.js.map +1 -1
- package/dist/languages/definitions/javascript.d.ts.map +1 -1
- package/dist/languages/definitions/javascript.js +10 -1
- package/dist/languages/definitions/javascript.js.map +1 -1
- package/dist/languages/definitions/js-family.d.ts +1 -1
- package/dist/languages/definitions/js-family.d.ts.map +1 -1
- package/dist/languages/definitions/js-family.js +7 -1
- package/dist/languages/definitions/js-family.js.map +1 -1
- package/dist/languages/definitions/php.d.ts.map +1 -1
- package/dist/languages/definitions/php.js +5 -1
- package/dist/languages/definitions/php.js.map +1 -1
- package/dist/languages/definitions/typescript.d.ts.map +1 -1
- package/dist/languages/definitions/typescript.js +8 -1
- package/dist/languages/definitions/typescript.js.map +1 -1
- package/dist/languages/definitions/zig.d.ts.map +1 -1
- package/dist/languages/definitions/zig.js +8 -0
- package/dist/languages/definitions/zig.js.map +1 -1
- package/dist/lifecycle/manifest.d.ts.map +1 -1
- package/dist/lifecycle/manifest.js +0 -1
- package/dist/lifecycle/manifest.js.map +1 -1
- package/dist/mcp/handlers.js +14 -7
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/native/byte-index.d.ts +6 -0
- package/dist/native/byte-index.d.ts.map +1 -1
- package/dist/native/byte-index.js +11 -6
- package/dist/native/byte-index.js.map +1 -1
- package/dist/native/contracts.d.ts +2 -3
- package/dist/native/contracts.d.ts.map +1 -1
- package/dist/native/execution.d.ts +9 -9
- package/dist/native/execution.d.ts.map +1 -1
- package/dist/native/execution.js +37 -77
- package/dist/native/execution.js.map +1 -1
- package/dist/native/js-bridge.d.ts +2 -15
- package/dist/native/js-bridge.d.ts.map +1 -1
- package/dist/native/js-bridge.js +2 -15
- package/dist/native/js-bridge.js.map +1 -1
- package/dist/native/query-results.js +2 -2
- package/dist/native/query-results.js.map +1 -1
- package/dist/native/runtime.d.ts +12 -12
- package/dist/native/runtime.d.ts.map +1 -1
- package/dist/native/runtime.js +24 -69
- package/dist/native/runtime.js.map +1 -1
- package/dist/native/tree-sitter-native.d.ts +3 -3
- package/dist/native/tree-sitter-native.d.ts.map +1 -1
- package/dist/native/tree-sitter-native.js +2 -2
- package/dist/native/tree-sitter-native.js.map +1 -1
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +0 -4
- package/dist/presets.js.map +1 -1
- package/dist/review/candidates.d.ts.map +1 -1
- package/dist/review/candidates.js +1 -1
- package/dist/review/candidates.js.map +1 -1
- package/dist/review/deleted.d.ts +3 -3
- package/dist/review/deleted.d.ts.map +1 -1
- package/dist/review/deleted.js +82 -32
- package/dist/review/deleted.js.map +1 -1
- package/dist/review/report.d.ts +1 -0
- package/dist/review/report.d.ts.map +1 -1
- package/dist/review/report.js +1 -1
- package/dist/review/report.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +3 -20
- package/dist/review.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +0 -5
- package/dist/session.js.map +1 -1
- package/dist/sql/navigation.d.ts.map +1 -1
- package/dist/sql/navigation.js +2 -1
- package/dist/sql/navigation.js.map +1 -1
- package/dist/sql/source-graph.d.ts.map +1 -1
- package/dist/sql/source-graph.js +2 -2
- package/dist/sql/source-graph.js.map +1 -1
- package/dist/sqlite/schema.d.ts +1 -1
- package/dist/sqlite/schema.d.ts.map +1 -1
- package/dist/sqlite/schema.js +8 -2
- package/dist/sqlite/schema.js.map +1 -1
- package/dist/sqlite/write.js +2 -2
- package/dist/sqlite/write.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/util/bloom-filter.d.ts +8 -1
- package/dist/util/bloom-filter.d.ts.map +1 -1
- package/dist/util/bloom-filter.js +15 -2
- package/dist/util/bloom-filter.js.map +1 -1
- package/dist/util/glob.d.ts +32 -0
- package/dist/util/glob.d.ts.map +1 -0
- package/dist/util/glob.js +137 -0
- package/dist/util/glob.js.map +1 -0
- package/dist/util/graph-edges.d.ts +19 -1
- package/dist/util/graph-edges.d.ts.map +1 -1
- package/dist/util/graph-edges.js +30 -4
- package/dist/util/graph-edges.js.map +1 -1
- package/dist/util/identifiers.d.ts +15 -0
- package/dist/util/identifiers.d.ts.map +1 -1
- package/dist/util/identifiers.js +35 -0
- package/dist/util/identifiers.js.map +1 -1
- package/dist/util/member-access-tables.d.ts +61 -4
- package/dist/util/member-access-tables.d.ts.map +1 -1
- package/dist/util/member-access-tables.js +139 -19
- package/dist/util/member-access-tables.js.map +1 -1
- package/dist/util/member-access.d.ts +17 -0
- package/dist/util/member-access.d.ts.map +1 -1
- package/dist/util/member-access.js +98 -3
- package/dist/util/member-access.js.map +1 -1
- package/dist/util/project-files.d.ts +2 -10
- package/dist/util/project-files.d.ts.map +1 -1
- package/dist/util/project-files.js +29 -51
- package/dist/util/project-files.js.map +1 -1
- package/dist/util/python-type-checking.d.ts +18 -0
- package/dist/util/python-type-checking.d.ts.map +1 -0
- package/dist/util/python-type-checking.js +160 -0
- package/dist/util/python-type-checking.js.map +1 -0
- package/dist/util/resolution/cargo-targets.d.ts +11 -0
- package/dist/util/resolution/cargo-targets.d.ts.map +1 -1
- package/dist/util/resolution/cargo-targets.js +174 -13
- package/dist/util/resolution/cargo-targets.js.map +1 -1
- package/dist/util/resolution/csharp.d.ts +33 -1
- package/dist/util/resolution/csharp.d.ts.map +1 -1
- package/dist/util/resolution/csharp.js +145 -30
- package/dist/util/resolution/csharp.js.map +1 -1
- package/dist/util/resolution/jvm.d.ts +7 -3
- package/dist/util/resolution/jvm.d.ts.map +1 -1
- package/dist/util/resolution/jvm.js +56 -38
- package/dist/util/resolution/jvm.js.map +1 -1
- package/dist/util/resolution/php.d.ts.map +1 -1
- package/dist/util/resolution/php.js +35 -8
- package/dist/util/resolution/php.js.map +1 -1
- package/dist/util/resolution/python.d.ts +9 -0
- package/dist/util/resolution/python.d.ts.map +1 -1
- package/dist/util/resolution/python.js +46 -0
- package/dist/util/resolution/python.js.map +1 -1
- package/dist/util/resolution/rust.d.ts +0 -1
- package/dist/util/resolution/rust.d.ts.map +1 -1
- package/dist/util/resolution/rust.js +95 -35
- package/dist/util/resolution/rust.js.map +1 -1
- package/dist/util/resolution/specifier-targets.d.ts +44 -0
- package/dist/util/resolution/specifier-targets.d.ts.map +1 -0
- package/dist/util/resolution/specifier-targets.js +152 -0
- package/dist/util/resolution/specifier-targets.js.map +1 -0
- package/dist/util/resolution-candidates.d.ts +5 -0
- package/dist/util/resolution-candidates.d.ts.map +1 -1
- package/dist/util/resolution-candidates.js +16 -3
- package/dist/util/resolution-candidates.js.map +1 -1
- package/dist/util/resolution.d.ts +2 -1
- package/dist/util/resolution.d.ts.map +1 -1
- package/dist/util/resolution.js +101 -15
- package/dist/util/resolution.js.map +1 -1
- package/dist/util/specifiers.d.ts +29 -1
- package/dist/util/specifiers.d.ts.map +1 -1
- package/dist/util/specifiers.js +56 -8
- package/dist/util/specifiers.js.map +1 -1
- package/dist/util/trivia.d.ts.map +1 -1
- package/dist/util/trivia.js +49 -30
- package/dist/util/trivia.js.map +1 -1
- package/dist/util/workspace.d.ts.map +1 -1
- package/dist/util/workspace.js +32 -4
- package/dist/util/workspace.js.map +1 -1
- package/docs/mcp.md +3 -2
- package/package.json +5 -7
- package/dist/impact/call-compatibility/providers/profiles.d.ts +0 -80
- package/dist/impact/call-compatibility/providers/profiles.d.ts.map +0 -1
- package/dist/impact/call-compatibility/providers/profiles.js +0 -164
- package/dist/impact/call-compatibility/providers/profiles.js.map +0 -1
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared callable arity facts derived from syntax trees.
|
|
3
|
+
*
|
|
4
|
+
* This leaf module is the single source of truth for two questions: how many explicit arguments a
|
|
5
|
+
* callable declaration accepts (`getCallableArity`) and how many explicit arguments a call passes
|
|
6
|
+
* (`getCallArgumentCount`). Impact analysis, the detailed symbol graph, and member navigation all
|
|
7
|
+
* consume these functions so one language rule cannot drift between consumers.
|
|
8
|
+
*
|
|
9
|
+
* Parameter and argument structure comes from parameter/argument nodes, not from comma-splitting
|
|
10
|
+
* spans: a generic type comma (`Map<String, Integer> value`) is not a parameter boundary, and a
|
|
11
|
+
* default value the grammar stores as a sibling of its parameter (Swift `default_value`, Kotlin's
|
|
12
|
+
* bare default expression) is not a second parameter. Unknown or unprovable shapes return null so
|
|
13
|
+
* callers can report unknown results instead of a wrong count.
|
|
14
|
+
*
|
|
15
|
+
* The module must stay a leaf: it may import only pure text scanning
|
|
16
|
+
* (`../impact/call-compatibility/text-scanner.js`) and `./types.js`, never navigation, scope,
|
|
17
|
+
* graph, or index-building code, so graph and navigation consumers can import it without a
|
|
18
|
+
* dependency cycle.
|
|
19
|
+
*/
|
|
20
|
+
import { findBalancedParentheses, findCommentEnd, findOpeningParen, splitTopLevelCommaGroups, } from "../impact/call-compatibility/text-scanner.js";
|
|
21
|
+
/**
|
|
22
|
+
* Call form that resolved C# member callsites use, shared by the detailed graph, receiver
|
|
23
|
+
* navigation, and impact. Codegraph resolves a C# extension method only through its declaring
|
|
24
|
+
* static class (`Ext.M(value)`, including alias- and namespace-qualified owners) or a bare call
|
|
25
|
+
* inside it, never through the extended value (`value.M()` needs receiver-type inference and
|
|
26
|
+
* stays unresolved), so the `this` receiver is an explicit argument at every resolved callsite.
|
|
27
|
+
* Every other language's member lookup binds the receiver.
|
|
28
|
+
*/
|
|
29
|
+
export function memberLookupBinding(languageId) {
|
|
30
|
+
return languageId === "csharp" ? "unbound" : "bound";
|
|
31
|
+
}
|
|
32
|
+
/** Node types that anchor a callable declaration when scanning up from a symbol position. */
|
|
33
|
+
export const CALLABLE_DECLARATION_NODE_TYPES = {
|
|
34
|
+
arrow_function: true,
|
|
35
|
+
constructor_declaration: true,
|
|
36
|
+
declaration: true,
|
|
37
|
+
function: true,
|
|
38
|
+
function_declaration: true,
|
|
39
|
+
function_declarator: true,
|
|
40
|
+
function_definition: true,
|
|
41
|
+
function_expression: true,
|
|
42
|
+
function_item: true,
|
|
43
|
+
function_signature_item: true,
|
|
44
|
+
generator_function_declaration: true,
|
|
45
|
+
init_declaration: true,
|
|
46
|
+
local_function_statement: true,
|
|
47
|
+
method: true,
|
|
48
|
+
method_declaration: true,
|
|
49
|
+
method_definition: true,
|
|
50
|
+
protocol_function_declaration: true,
|
|
51
|
+
singleton_method: true,
|
|
52
|
+
variable_declarator: true,
|
|
53
|
+
};
|
|
54
|
+
/** Node types whose value may be a callable for `variable_declarator` declarations. */
|
|
55
|
+
export const CALLABLE_VARIABLE_VALUE_NODE_TYPES = {
|
|
56
|
+
arrow_function: true,
|
|
57
|
+
function: true,
|
|
58
|
+
function_expression: true,
|
|
59
|
+
};
|
|
60
|
+
/** Parameter-list node types searched when the declaration exposes no parameter field. */
|
|
61
|
+
const PARAMETER_LIST_NODE_TYPES = {
|
|
62
|
+
formal_parameters: true,
|
|
63
|
+
function_parameter_clause: true,
|
|
64
|
+
function_value_parameters: true,
|
|
65
|
+
method_parameters: true,
|
|
66
|
+
parameter_list: true,
|
|
67
|
+
parameters: true,
|
|
68
|
+
};
|
|
69
|
+
/** Argument-list node types searched inside a call node. */
|
|
70
|
+
const ARGUMENT_LIST_NODE_TYPES = {
|
|
71
|
+
argument_list: true,
|
|
72
|
+
arguments: true,
|
|
73
|
+
value_arguments: true,
|
|
74
|
+
};
|
|
75
|
+
/** Call node types accepted when locating or climbing trailing-closure wrapper calls. */
|
|
76
|
+
const CALL_NODE_TYPES = {
|
|
77
|
+
call: true,
|
|
78
|
+
call_expression: true,
|
|
79
|
+
function_call_expression: true,
|
|
80
|
+
invocation_expression: true,
|
|
81
|
+
member_call_expression: true,
|
|
82
|
+
method_invocation: true,
|
|
83
|
+
object_creation_expression: true,
|
|
84
|
+
scoped_call_expression: true,
|
|
85
|
+
};
|
|
86
|
+
const GENERIC_PROFILE = {
|
|
87
|
+
receiver: {
|
|
88
|
+
nodeTypes: [],
|
|
89
|
+
firstParameterExact: [],
|
|
90
|
+
firstParameterTypedPrefixes: [],
|
|
91
|
+
phantomThisKeyword: null,
|
|
92
|
+
scopedFirstParameter: null,
|
|
93
|
+
},
|
|
94
|
+
directParameterChildType: null,
|
|
95
|
+
parameterSeparators: [],
|
|
96
|
+
restPrefixes: [],
|
|
97
|
+
restWordPatterns: [],
|
|
98
|
+
optionalNameMarker: null,
|
|
99
|
+
keywordParameterPattern: null,
|
|
100
|
+
keywordParameterValuePattern: null,
|
|
101
|
+
zeroSlotParameters: [],
|
|
102
|
+
parameterNodeTypes: [],
|
|
103
|
+
modifierNodeTypes: [],
|
|
104
|
+
zeroSlotNodeTypes: [],
|
|
105
|
+
restNodeTypes: [],
|
|
106
|
+
optionalNodeTypes: [],
|
|
107
|
+
mergeParameterRuns: false,
|
|
108
|
+
leadingNameSlots: false,
|
|
109
|
+
signatureCommaScanDetectsRegexLiterals: true,
|
|
110
|
+
sourceFallback: false,
|
|
111
|
+
callsiteParenthesesFallback: false,
|
|
112
|
+
spreadPrefixes: [],
|
|
113
|
+
spreadNodeTypes: [],
|
|
114
|
+
trailingClosureNodeTypes: [],
|
|
115
|
+
};
|
|
116
|
+
/** C-family rows: a bare `void` parameter list occupies zero slots. */
|
|
117
|
+
const cFamilyProfile = {
|
|
118
|
+
...GENERIC_PROFILE,
|
|
119
|
+
zeroSlotParameters: ["void"],
|
|
120
|
+
parameterNodeTypes: [
|
|
121
|
+
"parameter_declaration",
|
|
122
|
+
"optional_parameter_declaration",
|
|
123
|
+
"variadic_parameter",
|
|
124
|
+
"variadic_parameter_declaration",
|
|
125
|
+
],
|
|
126
|
+
restNodeTypes: ["variadic_parameter", "variadic_parameter_declaration"],
|
|
127
|
+
optionalNodeTypes: ["optional_parameter_declaration"],
|
|
128
|
+
};
|
|
129
|
+
/** ECMAScript-family rows: `this` parameters, `?`-marked optionals, and the source-level fallback. */
|
|
130
|
+
const jsFamilyProfile = {
|
|
131
|
+
...GENERIC_PROFILE,
|
|
132
|
+
receiver: {
|
|
133
|
+
...GENERIC_PROFILE.receiver,
|
|
134
|
+
// `this` parameters are type-only receivers at any position; never an argument slot.
|
|
135
|
+
phantomThisKeyword: "this",
|
|
136
|
+
},
|
|
137
|
+
parameterNodeTypes: ["required_parameter", "optional_parameter"],
|
|
138
|
+
optionalNodeTypes: ["optional_parameter"],
|
|
139
|
+
optionalNameMarker: "?",
|
|
140
|
+
// The AST path can fail where the source still shows the call, so paren scanning rescues it.
|
|
141
|
+
sourceFallback: true,
|
|
142
|
+
};
|
|
143
|
+
/** Python rows: class-scoped first parameters are receivers; separators and rest markers diverge. */
|
|
144
|
+
const pythonProfile = {
|
|
145
|
+
...GENERIC_PROFILE,
|
|
146
|
+
receiver: {
|
|
147
|
+
...GENERIC_PROFILE.receiver,
|
|
148
|
+
// Instance and class methods drop their first parameter; static methods and module functions
|
|
149
|
+
// keep it as an ordinary slot whatever its spelling.
|
|
150
|
+
scopedFirstParameter: {
|
|
151
|
+
methodScopeTypes: ["class_definition"],
|
|
152
|
+
nonMethodScopeTypes: ["function_definition"],
|
|
153
|
+
staticDecorators: ["staticmethod"],
|
|
154
|
+
classDecorators: ["classmethod"],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
parameterNodeTypes: [
|
|
158
|
+
"identifier",
|
|
159
|
+
"default_parameter",
|
|
160
|
+
"typed_parameter",
|
|
161
|
+
"typed_default_parameter",
|
|
162
|
+
"list_splat_pattern",
|
|
163
|
+
"dictionary_splat_pattern",
|
|
164
|
+
"tuple_pattern",
|
|
165
|
+
],
|
|
166
|
+
zeroSlotNodeTypes: ["positional_separator", "keyword_separator"],
|
|
167
|
+
restNodeTypes: ["list_splat_pattern", "dictionary_splat_pattern"],
|
|
168
|
+
optionalNodeTypes: ["default_parameter", "typed_default_parameter"],
|
|
169
|
+
parameterSeparators: ["/", "*"],
|
|
170
|
+
restPrefixes: ["*"],
|
|
171
|
+
spreadPrefixes: ["*"],
|
|
172
|
+
spreadNodeTypes: ["list_splat", "dictionary_splat"],
|
|
173
|
+
// `/` is the positional-only separator, so the signature comma-scan cannot treat `/.../` as a regex.
|
|
174
|
+
signatureCommaScanDetectsRegexLiterals: false,
|
|
175
|
+
};
|
|
176
|
+
/** Ruby rows: `self` is the only receiver spelling; block capture occupies no positional slot. */
|
|
177
|
+
const rubyProfile = {
|
|
178
|
+
...GENERIC_PROFILE,
|
|
179
|
+
receiver: {
|
|
180
|
+
...GENERIC_PROFILE.receiver,
|
|
181
|
+
// `cls` and other names are ordinary parameters; only error-recovered `self` is a receiver.
|
|
182
|
+
firstParameterExact: ["self"],
|
|
183
|
+
},
|
|
184
|
+
parameterNodeTypes: [
|
|
185
|
+
"identifier",
|
|
186
|
+
"optional_parameter",
|
|
187
|
+
"splat_parameter",
|
|
188
|
+
"hash_splat_parameter",
|
|
189
|
+
"keyword_parameter",
|
|
190
|
+
"keyword_rest_parameter",
|
|
191
|
+
"block_parameter",
|
|
192
|
+
"proc_parameter",
|
|
193
|
+
"forward_parameter",
|
|
194
|
+
"bare_parameter",
|
|
195
|
+
"rest_parameter",
|
|
196
|
+
],
|
|
197
|
+
zeroSlotNodeTypes: ["block_parameter", "proc_parameter"],
|
|
198
|
+
restNodeTypes: [
|
|
199
|
+
"splat_parameter",
|
|
200
|
+
"hash_splat_parameter",
|
|
201
|
+
"keyword_rest_parameter",
|
|
202
|
+
"forward_parameter",
|
|
203
|
+
"rest_parameter",
|
|
204
|
+
],
|
|
205
|
+
optionalNodeTypes: ["optional_parameter"],
|
|
206
|
+
restPrefixes: ["*"],
|
|
207
|
+
spreadPrefixes: ["*"],
|
|
208
|
+
keywordParameterPattern: /^[A-Za-z_]\w*:/,
|
|
209
|
+
keywordParameterValuePattern: /^[A-Za-z_]\w*:\s*\S/,
|
|
210
|
+
};
|
|
211
|
+
/** Rust rows: `self_parameter` receivers, including typed `self:` forms. */
|
|
212
|
+
const rustProfile = {
|
|
213
|
+
...GENERIC_PROFILE,
|
|
214
|
+
receiver: {
|
|
215
|
+
...GENERIC_PROFILE.receiver,
|
|
216
|
+
nodeTypes: ["self_parameter"],
|
|
217
|
+
firstParameterExact: ["self", "&self", "&mut self"],
|
|
218
|
+
firstParameterTypedPrefixes: ["self:"],
|
|
219
|
+
},
|
|
220
|
+
parameterNodeTypes: ["parameter", "self_parameter"],
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Language ids the callable-arity extractors declare support for, in diagnostics order. The list is
|
|
224
|
+
* filtered against the registry by the call-compatibility provider registry so a stale id can never
|
|
225
|
+
* be reported as supported.
|
|
226
|
+
*/
|
|
227
|
+
export const CALLABLE_ARITY_LANGUAGE_ID_DECLARATIONS = [
|
|
228
|
+
"c",
|
|
229
|
+
"cpp",
|
|
230
|
+
"csharp",
|
|
231
|
+
"go",
|
|
232
|
+
"java",
|
|
233
|
+
"js",
|
|
234
|
+
"kotlin",
|
|
235
|
+
"php",
|
|
236
|
+
"python",
|
|
237
|
+
"ruby",
|
|
238
|
+
"rust",
|
|
239
|
+
"swift",
|
|
240
|
+
"ts",
|
|
241
|
+
"tsx",
|
|
242
|
+
"zig",
|
|
243
|
+
];
|
|
244
|
+
export const CALLABLE_ARITY_LANGUAGE_PROFILES = {
|
|
245
|
+
c: cFamilyProfile,
|
|
246
|
+
cpp: cFamilyProfile,
|
|
247
|
+
// `params` marks the rest parameter; the pinned grammar flattens `params` forms into list children.
|
|
248
|
+
// An extension method's leading `this T value` parameter (a `modifier` child spelled `this`) is its
|
|
249
|
+
// receiver: `value.M()` supplies it, while `Ext.M(value)` passes it explicitly.
|
|
250
|
+
csharp: {
|
|
251
|
+
...GENERIC_PROFILE,
|
|
252
|
+
receiver: { ...GENERIC_PROFILE.receiver, firstParameterTypedPrefixes: ["this "] },
|
|
253
|
+
parameterNodeTypes: ["parameter"],
|
|
254
|
+
mergeParameterRuns: true,
|
|
255
|
+
restWordPatterns: [/\bparams\b/],
|
|
256
|
+
},
|
|
257
|
+
// Grouped names `a, b string` share one parameter node; `...string` variadics are node-typed.
|
|
258
|
+
go: {
|
|
259
|
+
...GENERIC_PROFILE,
|
|
260
|
+
parameterNodeTypes: ["parameter_declaration"],
|
|
261
|
+
restNodeTypes: ["variadic_parameter_declaration"],
|
|
262
|
+
leadingNameSlots: true,
|
|
263
|
+
},
|
|
264
|
+
// `receiver_parameter` nodes are explicit receivers; `spread_parameter` nodes are variadic.
|
|
265
|
+
java: {
|
|
266
|
+
...GENERIC_PROFILE,
|
|
267
|
+
receiver: { ...GENERIC_PROFILE.receiver, nodeTypes: ["receiver_parameter"] },
|
|
268
|
+
parameterNodeTypes: ["formal_parameter", "receiver_parameter", "spread_parameter"],
|
|
269
|
+
restNodeTypes: ["spread_parameter"],
|
|
270
|
+
},
|
|
271
|
+
js: jsFamilyProfile,
|
|
272
|
+
ts: jsFamilyProfile,
|
|
273
|
+
tsx: jsFamilyProfile,
|
|
274
|
+
// `vararg` rides a parameter_modifiers sibling; spread calls (`*values`) are uncountable.
|
|
275
|
+
kotlin: {
|
|
276
|
+
...GENERIC_PROFILE,
|
|
277
|
+
parameterNodeTypes: ["parameter"],
|
|
278
|
+
modifierNodeTypes: ["parameter_modifiers", "parameter_modifier"],
|
|
279
|
+
restWordPatterns: [/\bvararg\b/],
|
|
280
|
+
spreadPrefixes: ["*"],
|
|
281
|
+
spreadNodeTypes: ["spread_expression"],
|
|
282
|
+
trailingClosureNodeTypes: ["annotated_lambda"],
|
|
283
|
+
},
|
|
284
|
+
// `...$rest` spreads ride the generic leading-`...` rules; promotion parameters are plain slots.
|
|
285
|
+
php: {
|
|
286
|
+
...GENERIC_PROFILE,
|
|
287
|
+
parameterNodeTypes: ["simple_parameter", "variadic_parameter", "property_promotion_parameter"],
|
|
288
|
+
restNodeTypes: ["variadic_parameter"],
|
|
289
|
+
spreadNodeTypes: ["variadic_parameter"],
|
|
290
|
+
},
|
|
291
|
+
python: pythonProfile,
|
|
292
|
+
ruby: rubyProfile,
|
|
293
|
+
rust: rustProfile,
|
|
294
|
+
// Parameter clauses expose no list node; span the declaration's direct `parameter` children.
|
|
295
|
+
swift: {
|
|
296
|
+
...GENERIC_PROFILE,
|
|
297
|
+
directParameterChildType: "parameter",
|
|
298
|
+
trailingClosureNodeTypes: ["lambda_literal"],
|
|
299
|
+
},
|
|
300
|
+
// Callsites expose no argument-list node; scan for the call parentheses instead.
|
|
301
|
+
zig: {
|
|
302
|
+
...GENERIC_PROFILE,
|
|
303
|
+
receiver: { ...GENERIC_PROFILE.receiver, firstParameterTypedPrefixes: ["self:", "self :"] },
|
|
304
|
+
parameterNodeTypes: ["parameter"],
|
|
305
|
+
callsiteParenthesesFallback: true,
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Resolved arity profile for a language id, or null when the id is not a declared arity language.
|
|
310
|
+
* The extractors branch on this profile, never on language ids.
|
|
311
|
+
*/
|
|
312
|
+
export function getCallableArityProfile(languageId) {
|
|
313
|
+
if (!CALLABLE_ARITY_LANGUAGE_ID_DECLARATIONS.includes(languageId)) {
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
return CALLABLE_ARITY_LANGUAGE_PROFILES[languageId];
|
|
317
|
+
}
|
|
318
|
+
function hasTopLevelEquals(text) {
|
|
319
|
+
let parenDepth = 0;
|
|
320
|
+
let bracketDepth = 0;
|
|
321
|
+
let braceDepth = 0;
|
|
322
|
+
let angleDepth = 0;
|
|
323
|
+
let quote = null;
|
|
324
|
+
let escaped = false;
|
|
325
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
326
|
+
const char = text[index];
|
|
327
|
+
if (quote) {
|
|
328
|
+
if (escaped) {
|
|
329
|
+
escaped = false;
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
if (char === "\\") {
|
|
333
|
+
escaped = true;
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (char === quote) {
|
|
337
|
+
quote = null;
|
|
338
|
+
}
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
const commentEnd = findCommentEnd(text, index);
|
|
342
|
+
if (commentEnd !== null) {
|
|
343
|
+
if (commentEnd < 0) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
index = commentEnd - 1;
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
350
|
+
quote = char;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
if (char === "(") {
|
|
354
|
+
parenDepth += 1;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (char === ")") {
|
|
358
|
+
parenDepth -= 1;
|
|
359
|
+
if (parenDepth < 0) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (char === "[") {
|
|
365
|
+
bracketDepth += 1;
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (char === "]") {
|
|
369
|
+
bracketDepth -= 1;
|
|
370
|
+
if (bracketDepth < 0) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (char === "{") {
|
|
376
|
+
braceDepth += 1;
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
if (char === "}") {
|
|
380
|
+
braceDepth -= 1;
|
|
381
|
+
if (braceDepth < 0) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
const atTopLevel = !parenDepth && !bracketDepth && !braceDepth;
|
|
387
|
+
if (char === "<" && atTopLevel) {
|
|
388
|
+
angleDepth += 1;
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (char === ">" && text[index - 1] !== "=" && atTopLevel && angleDepth) {
|
|
392
|
+
angleDepth -= 1;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (char === "=" && text[index + 1] !== ">" && atTopLevel && !angleDepth) {
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
function hasTopLevelEllipsis(text) {
|
|
402
|
+
let parenDepth = 0;
|
|
403
|
+
let bracketDepth = 0;
|
|
404
|
+
let braceDepth = 0;
|
|
405
|
+
let angleDepth = 0;
|
|
406
|
+
let quote = null;
|
|
407
|
+
let escaped = false;
|
|
408
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
409
|
+
const char = text[index];
|
|
410
|
+
if (quote) {
|
|
411
|
+
if (escaped) {
|
|
412
|
+
escaped = false;
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
if (char === "\\") {
|
|
416
|
+
escaped = true;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (char === quote) {
|
|
420
|
+
quote = null;
|
|
421
|
+
}
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
const commentEnd = findCommentEnd(text, index);
|
|
425
|
+
if (commentEnd !== null) {
|
|
426
|
+
if (commentEnd < 0) {
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
index = commentEnd - 1;
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
if (canStartRegexLiteral(text, index)) {
|
|
433
|
+
const regexEnd = findRegexLiteralEnd(text, index);
|
|
434
|
+
if (regexEnd === null || regexEnd < 0) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
index = regexEnd - 1;
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
441
|
+
quote = char;
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (char === "(") {
|
|
445
|
+
parenDepth += 1;
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (char === ")") {
|
|
449
|
+
parenDepth -= 1;
|
|
450
|
+
if (parenDepth < 0) {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (char === "[") {
|
|
456
|
+
bracketDepth += 1;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (char === "]") {
|
|
460
|
+
bracketDepth -= 1;
|
|
461
|
+
if (bracketDepth < 0) {
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (char === "{") {
|
|
467
|
+
braceDepth += 1;
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (char === "}") {
|
|
471
|
+
braceDepth -= 1;
|
|
472
|
+
if (braceDepth < 0) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
const atDelimiterTopLevel = !parenDepth && !bracketDepth && !braceDepth;
|
|
478
|
+
if (char === "<" && atDelimiterTopLevel) {
|
|
479
|
+
angleDepth += 1;
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
if (char === ">" && angleDepth && atDelimiterTopLevel && text[index - 1] !== "=") {
|
|
483
|
+
angleDepth -= 1;
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (!angleDepth && atDelimiterTopLevel && text.startsWith("...", index)) {
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
function canStartRegexLiteral(text, index) {
|
|
493
|
+
if (text[index] !== "/" || text[index + 1] === "/" || text[index + 1] === "*") {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
let previous = null;
|
|
497
|
+
for (let current = index - 1; current >= 0; current -= 1) {
|
|
498
|
+
const char = text[current];
|
|
499
|
+
if (char !== undefined && !/\s/.test(char)) {
|
|
500
|
+
previous = char;
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (!previous) {
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
return "([{,=:+-!*?&|;".includes(previous);
|
|
508
|
+
}
|
|
509
|
+
function findRegexLiteralEnd(text, index) {
|
|
510
|
+
if (text[index] !== "/" || text[index + 1] === "/" || text[index + 1] === "*") {
|
|
511
|
+
return null;
|
|
512
|
+
}
|
|
513
|
+
let escaped = false;
|
|
514
|
+
let inCharacterClass = false;
|
|
515
|
+
for (let current = index + 1; current < text.length; current += 1) {
|
|
516
|
+
const char = text[current];
|
|
517
|
+
if (char === "\n" || char === "\r") {
|
|
518
|
+
return -1;
|
|
519
|
+
}
|
|
520
|
+
if (escaped) {
|
|
521
|
+
escaped = false;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (char === "\\") {
|
|
525
|
+
escaped = true;
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
if (char === "[") {
|
|
529
|
+
inCharacterClass = true;
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
if (char === "]") {
|
|
533
|
+
inCharacterClass = false;
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
if (char === "/" && !inCharacterClass) {
|
|
537
|
+
let endIndex = current + 1;
|
|
538
|
+
while (/[A-Za-z]/.test(text[endIndex] ?? "")) {
|
|
539
|
+
endIndex += 1;
|
|
540
|
+
}
|
|
541
|
+
return endIndex;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return -1;
|
|
545
|
+
}
|
|
546
|
+
function sliceOf(source, node) {
|
|
547
|
+
return source.slice(node.startIndex, node.endIndex);
|
|
548
|
+
}
|
|
549
|
+
function isNamedChild(parent, child) {
|
|
550
|
+
for (const named of parent.namedChildren ?? []) {
|
|
551
|
+
if (named.startIndex === child.startIndex && named.type === child.type) {
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
function nameBeforeFirstColon(text) {
|
|
558
|
+
const colonIndex = text.indexOf(":");
|
|
559
|
+
const namePortion = colonIndex >= 0 ? text.slice(0, colonIndex) : text;
|
|
560
|
+
return namePortion.trim();
|
|
561
|
+
}
|
|
562
|
+
function decoratorName(node) {
|
|
563
|
+
if (node.type === "identifier") {
|
|
564
|
+
return node.text;
|
|
565
|
+
}
|
|
566
|
+
if (node.type === "attribute") {
|
|
567
|
+
let last = null;
|
|
568
|
+
for (const nested of node.namedChildren ?? []) {
|
|
569
|
+
if (nested.type === "identifier") {
|
|
570
|
+
last = nested.text;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return last;
|
|
574
|
+
}
|
|
575
|
+
if (node.type === "call") {
|
|
576
|
+
const callee = node.childForFieldName("function") ?? node.childForFieldName("decorator") ?? null;
|
|
577
|
+
return callee ? decoratorName(callee) : null;
|
|
578
|
+
}
|
|
579
|
+
for (const child of node.namedChildren ?? []) {
|
|
580
|
+
const name = decoratorName(child);
|
|
581
|
+
if (name !== null) {
|
|
582
|
+
return name;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
function scopedKindOf(declaration, rule) {
|
|
588
|
+
let scopeKind = null;
|
|
589
|
+
let current = declaration.parent;
|
|
590
|
+
while (current && scopeKind === null) {
|
|
591
|
+
if (rule.methodScopeTypes.includes(current.type)) {
|
|
592
|
+
scopeKind = "method";
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
if (rule.nonMethodScopeTypes.includes(current.type)) {
|
|
596
|
+
scopeKind = "function";
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
current = current.parent;
|
|
600
|
+
}
|
|
601
|
+
if (scopeKind !== "method") {
|
|
602
|
+
return "function";
|
|
603
|
+
}
|
|
604
|
+
let decoratorOwner = declaration.parent;
|
|
605
|
+
while (decoratorOwner) {
|
|
606
|
+
if (decoratorOwner.type === "decorated_definition") {
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
if (rule.methodScopeTypes.includes(decoratorOwner.type)) {
|
|
610
|
+
decoratorOwner = null;
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
decoratorOwner = decoratorOwner.parent;
|
|
614
|
+
}
|
|
615
|
+
for (const child of decoratorOwner?.namedChildren ?? []) {
|
|
616
|
+
if (child.type !== "decorator") {
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
const name = decoratorName(child);
|
|
620
|
+
if (name !== null && rule.staticDecorators.includes(name)) {
|
|
621
|
+
return "static-method";
|
|
622
|
+
}
|
|
623
|
+
if (name !== null && rule.classDecorators.includes(name)) {
|
|
624
|
+
return "class-method";
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return "instance-method";
|
|
628
|
+
}
|
|
629
|
+
function receiverMatchFor(profile, parameter, index, kind) {
|
|
630
|
+
const phantomKeyword = profile.receiver.phantomThisKeyword;
|
|
631
|
+
if (phantomKeyword !== null && nameBeforeFirstColon(parameter.text) === phantomKeyword) {
|
|
632
|
+
return "phantom";
|
|
633
|
+
}
|
|
634
|
+
if (parameter.nodeType !== null && profile.receiver.nodeTypes.includes(parameter.nodeType)) {
|
|
635
|
+
return "bound-receiver";
|
|
636
|
+
}
|
|
637
|
+
if (index) {
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
640
|
+
const trimmed = parameter.text.trim();
|
|
641
|
+
if (profile.receiver.firstParameterExact.includes(trimmed)) {
|
|
642
|
+
return "bound-receiver";
|
|
643
|
+
}
|
|
644
|
+
if (profile.receiver.firstParameterTypedPrefixes.some((prefix) => trimmed.startsWith(prefix))) {
|
|
645
|
+
return "bound-receiver";
|
|
646
|
+
}
|
|
647
|
+
const scopedRule = profile.receiver.scopedFirstParameter;
|
|
648
|
+
if (scopedRule && (kind === "instance-method" || kind === "class-method")) {
|
|
649
|
+
return "bound-receiver";
|
|
650
|
+
}
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
653
|
+
function isRestParameter(profile, parameter) {
|
|
654
|
+
const trimmed = parameter.trim();
|
|
655
|
+
if (!trimmed) {
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
658
|
+
if (hasTopLevelEllipsis(trimmed)) {
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
661
|
+
if (profile.restPrefixes.some((prefix) => trimmed.startsWith(prefix))) {
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
return profile.restWordPatterns.some((pattern) => pattern.test(trimmed));
|
|
665
|
+
}
|
|
666
|
+
function isOptionalParameter(profile, parameter) {
|
|
667
|
+
const trimmed = parameter.trim();
|
|
668
|
+
if (!trimmed) {
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
const nameMarker = profile.optionalNameMarker;
|
|
672
|
+
if (nameMarker !== null) {
|
|
673
|
+
const namePortion = nameBeforeFirstColon(trimmed);
|
|
674
|
+
if (namePortion.includes(nameMarker)) {
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (profile.keywordParameterValuePattern?.test(trimmed)) {
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
return hasTopLevelEquals(trimmed);
|
|
682
|
+
}
|
|
683
|
+
function parameterSlotCount(profile, parameterNode, text) {
|
|
684
|
+
const trimmed = text.trim();
|
|
685
|
+
if (!trimmed) {
|
|
686
|
+
return 0;
|
|
687
|
+
}
|
|
688
|
+
if (profile.zeroSlotParameters.includes(trimmed)) {
|
|
689
|
+
return 0;
|
|
690
|
+
}
|
|
691
|
+
if (profile.leadingNameSlots && parameterNode) {
|
|
692
|
+
let names = 0;
|
|
693
|
+
for (const child of parameterNode.namedChildren ?? []) {
|
|
694
|
+
if (child.type === "identifier") {
|
|
695
|
+
names += 1;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return names > 0 ? names : 1;
|
|
699
|
+
}
|
|
700
|
+
return 1;
|
|
701
|
+
}
|
|
702
|
+
function isParameterNodeType(profile, type) {
|
|
703
|
+
return (profile.parameterNodeTypes.includes(type) ||
|
|
704
|
+
profile.zeroSlotNodeTypes.includes(type) ||
|
|
705
|
+
profile.restNodeTypes.includes(type) ||
|
|
706
|
+
profile.optionalNodeTypes.includes(type));
|
|
707
|
+
}
|
|
708
|
+
function findParameterRegion(declaration, profile) {
|
|
709
|
+
const direct = declaration.childForFieldName("parameters") ??
|
|
710
|
+
declaration.childForFieldName("params") ??
|
|
711
|
+
declaration.childForFieldName("parameter");
|
|
712
|
+
if (direct) {
|
|
713
|
+
if (PARAMETER_LIST_NODE_TYPES[direct.type]) {
|
|
714
|
+
return { kind: "list", node: direct };
|
|
715
|
+
}
|
|
716
|
+
return { kind: "single", node: direct };
|
|
717
|
+
}
|
|
718
|
+
if (declaration.type === "variable_declarator") {
|
|
719
|
+
const valueNode = declaration.childForFieldName("value");
|
|
720
|
+
if (!valueNode || !CALLABLE_VARIABLE_VALUE_NODE_TYPES[valueNode.type]) {
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
return findParameterRegion(valueNode, profile);
|
|
724
|
+
}
|
|
725
|
+
for (const child of declaration.namedChildren ?? []) {
|
|
726
|
+
if (PARAMETER_LIST_NODE_TYPES[child.type]) {
|
|
727
|
+
return { kind: "list", node: child };
|
|
728
|
+
}
|
|
729
|
+
const nested = findNestedParameterList(child);
|
|
730
|
+
if (nested) {
|
|
731
|
+
return { kind: "list", node: nested };
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
const directType = profile.directParameterChildType;
|
|
735
|
+
if (directType !== null) {
|
|
736
|
+
return { kind: "direct", declaration, parameterType: directType };
|
|
737
|
+
}
|
|
738
|
+
return null;
|
|
739
|
+
}
|
|
740
|
+
function findNestedParameterList(node) {
|
|
741
|
+
for (const child of node.namedChildren ?? []) {
|
|
742
|
+
if (PARAMETER_LIST_NODE_TYPES[child.type]) {
|
|
743
|
+
return child;
|
|
744
|
+
}
|
|
745
|
+
const nested = findNestedParameterList(child);
|
|
746
|
+
if (nested) {
|
|
747
|
+
return nested;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
752
|
+
function enumerateListParameters(profile, region, source) {
|
|
753
|
+
const parameters = [];
|
|
754
|
+
let hasRest = false;
|
|
755
|
+
let prefixText = "";
|
|
756
|
+
let sawEquals = false;
|
|
757
|
+
let last = null;
|
|
758
|
+
let lastEndIndex = region.startIndex;
|
|
759
|
+
let runStartIndex = -1;
|
|
760
|
+
let runEndIndex = -1;
|
|
761
|
+
const flushRun = () => {
|
|
762
|
+
if (runStartIndex < 0) {
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
const runText = source.slice(runStartIndex, runEndIndex);
|
|
766
|
+
const fact = {
|
|
767
|
+
text: `${prefixText}${runText}`,
|
|
768
|
+
nodeType: null,
|
|
769
|
+
slots: parameterSlotCount(profile, null, runText),
|
|
770
|
+
forcedOptional: false,
|
|
771
|
+
forcedRest: false,
|
|
772
|
+
forcedZeroSlot: false,
|
|
773
|
+
};
|
|
774
|
+
prefixText = "";
|
|
775
|
+
lastEndIndex = runEndIndex;
|
|
776
|
+
last = fact;
|
|
777
|
+
parameters.push(fact);
|
|
778
|
+
runStartIndex = -1;
|
|
779
|
+
runEndIndex = -1;
|
|
780
|
+
};
|
|
781
|
+
for (let index = 0;; index += 1) {
|
|
782
|
+
const child = region.child(index);
|
|
783
|
+
if (!child) {
|
|
784
|
+
break;
|
|
785
|
+
}
|
|
786
|
+
if (child.type === "comment") {
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
if (child.type === "ERROR" || child.type === "MISSING") {
|
|
790
|
+
return null;
|
|
791
|
+
}
|
|
792
|
+
if (!isNamedChild(region, child)) {
|
|
793
|
+
const trimmed = child.text.trim();
|
|
794
|
+
if (trimmed === "=") {
|
|
795
|
+
sawEquals = true;
|
|
796
|
+
continue;
|
|
797
|
+
}
|
|
798
|
+
if (trimmed === "...") {
|
|
799
|
+
hasRest = true;
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
if (trimmed === "," || trimmed === "(" || trimmed === ")") {
|
|
803
|
+
flushRun();
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
if (profile.mergeParameterRuns && trimmed) {
|
|
807
|
+
if (runStartIndex < 0) {
|
|
808
|
+
runStartIndex = child.startIndex;
|
|
809
|
+
}
|
|
810
|
+
runEndIndex = child.endIndex;
|
|
811
|
+
lastEndIndex = child.endIndex;
|
|
812
|
+
sawEquals = false;
|
|
813
|
+
}
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
if (profile.modifierNodeTypes.includes(child.type)) {
|
|
817
|
+
prefixText += `${sliceOf(source, child)} `;
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
if (isParameterNodeType(profile, child.type)) {
|
|
821
|
+
flushRun();
|
|
822
|
+
const fact = {
|
|
823
|
+
text: `${prefixText}${sliceOf(source, child)}`,
|
|
824
|
+
nodeType: child.type,
|
|
825
|
+
slots: parameterSlotCount(profile, child, sliceOf(source, child)),
|
|
826
|
+
forcedOptional: profile.optionalNodeTypes.includes(child.type),
|
|
827
|
+
forcedRest: profile.restNodeTypes.includes(child.type),
|
|
828
|
+
forcedZeroSlot: profile.zeroSlotNodeTypes.includes(child.type),
|
|
829
|
+
};
|
|
830
|
+
prefixText = "";
|
|
831
|
+
sawEquals = false;
|
|
832
|
+
lastEndIndex = child.endIndex;
|
|
833
|
+
last = fact;
|
|
834
|
+
parameters.push(fact);
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
const gap = source.slice(lastEndIndex, child.startIndex);
|
|
838
|
+
if (last && (sawEquals || gap.includes("="))) {
|
|
839
|
+
flushRun();
|
|
840
|
+
last.forcedOptional = true;
|
|
841
|
+
sawEquals = false;
|
|
842
|
+
lastEndIndex = child.endIndex;
|
|
843
|
+
continue;
|
|
844
|
+
}
|
|
845
|
+
if (!profile.mergeParameterRuns) {
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
if (runStartIndex < 0) {
|
|
849
|
+
runStartIndex = child.startIndex;
|
|
850
|
+
}
|
|
851
|
+
runEndIndex = child.endIndex;
|
|
852
|
+
lastEndIndex = child.endIndex;
|
|
853
|
+
sawEquals = false;
|
|
854
|
+
}
|
|
855
|
+
flushRun();
|
|
856
|
+
return { parameters, hasRest };
|
|
857
|
+
}
|
|
858
|
+
function enumerateDirectParameters(profile, region, source) {
|
|
859
|
+
const parameters = [];
|
|
860
|
+
let last = null;
|
|
861
|
+
let lastEndIndex = region.declaration.startIndex;
|
|
862
|
+
for (const child of region.declaration.namedChildren ?? []) {
|
|
863
|
+
if (child.type !== region.parameterType) {
|
|
864
|
+
if (last === null) {
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
const gap = source.slice(lastEndIndex, child.startIndex);
|
|
868
|
+
if (gap.includes("=")) {
|
|
869
|
+
last.forcedOptional = true;
|
|
870
|
+
lastEndIndex = child.endIndex;
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
const fact = {
|
|
876
|
+
text: sliceOf(source, child),
|
|
877
|
+
nodeType: child.type,
|
|
878
|
+
slots: parameterSlotCount(profile, child, sliceOf(source, child)),
|
|
879
|
+
forcedOptional: false,
|
|
880
|
+
forcedRest: false,
|
|
881
|
+
forcedZeroSlot: false,
|
|
882
|
+
};
|
|
883
|
+
lastEndIndex = child.endIndex;
|
|
884
|
+
last = fact;
|
|
885
|
+
parameters.push(fact);
|
|
886
|
+
}
|
|
887
|
+
return { parameters, hasRest: false };
|
|
888
|
+
}
|
|
889
|
+
function enumerateParameters(profile, declaration, source) {
|
|
890
|
+
const region = findParameterRegion(declaration, profile);
|
|
891
|
+
if (region === null) {
|
|
892
|
+
if (declaration.type === "variable_declarator") {
|
|
893
|
+
return null;
|
|
894
|
+
}
|
|
895
|
+
if (CALLABLE_DECLARATION_NODE_TYPES[declaration.type]) {
|
|
896
|
+
return { parameters: [], hasRest: false };
|
|
897
|
+
}
|
|
898
|
+
return null;
|
|
899
|
+
}
|
|
900
|
+
if (region.kind === "single") {
|
|
901
|
+
const text = sliceOf(source, region.node);
|
|
902
|
+
return {
|
|
903
|
+
parameters: [
|
|
904
|
+
{
|
|
905
|
+
text,
|
|
906
|
+
nodeType: region.node.type,
|
|
907
|
+
slots: parameterSlotCount(profile, region.node, text),
|
|
908
|
+
forcedOptional: profile.optionalNodeTypes.includes(region.node.type),
|
|
909
|
+
forcedRest: profile.restNodeTypes.includes(region.node.type),
|
|
910
|
+
forcedZeroSlot: profile.zeroSlotNodeTypes.includes(region.node.type),
|
|
911
|
+
},
|
|
912
|
+
],
|
|
913
|
+
hasRest: false,
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
if (region.kind === "direct") {
|
|
917
|
+
return enumerateDirectParameters(profile, region, source);
|
|
918
|
+
}
|
|
919
|
+
return enumerateListParameters(profile, region.node, source);
|
|
920
|
+
}
|
|
921
|
+
function kindFor(profile, declaration, parameters) {
|
|
922
|
+
const scopedRule = profile.receiver.scopedFirstParameter;
|
|
923
|
+
if (scopedRule) {
|
|
924
|
+
return scopedKindOf(declaration, scopedRule);
|
|
925
|
+
}
|
|
926
|
+
const hasReceiver = parameters.some((parameter, index) => receiverMatchFor(profile, parameter, index, "function") === "bound-receiver");
|
|
927
|
+
return hasReceiver ? "instance-method" : "function";
|
|
928
|
+
}
|
|
929
|
+
function arityOfParameters(profile, parameters, initialHasRest, binding, kind) {
|
|
930
|
+
let minArgs = 0;
|
|
931
|
+
let maxArgs = 0;
|
|
932
|
+
let positionalArgCount = 0;
|
|
933
|
+
let hasRest = initialHasRest;
|
|
934
|
+
parameters.forEach((parameter, index) => {
|
|
935
|
+
const trimmed = parameter.text.trim();
|
|
936
|
+
if (!trimmed || profile.parameterSeparators.includes(trimmed)) {
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
const receiver = receiverMatchFor(profile, parameter, index, kind);
|
|
940
|
+
if (receiver === "phantom") {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
if (receiver === "bound-receiver" && binding === "bound") {
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
if (parameter.forcedZeroSlot) {
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (parameter.forcedRest || isRestParameter(profile, trimmed)) {
|
|
950
|
+
hasRest = true;
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
const optional = parameter.forcedOptional || isOptionalParameter(profile, trimmed);
|
|
954
|
+
if (profile.keywordParameterPattern?.test(trimmed)) {
|
|
955
|
+
maxArgs += 1;
|
|
956
|
+
if (!optional) {
|
|
957
|
+
minArgs += 1;
|
|
958
|
+
}
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
const slotCount = parameter.slots;
|
|
962
|
+
if (!slotCount) {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
positionalArgCount += slotCount;
|
|
966
|
+
maxArgs += slotCount;
|
|
967
|
+
if (!optional) {
|
|
968
|
+
minArgs = positionalArgCount;
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
return { minArgs, maxArgs: hasRest ? null : maxArgs };
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Accepted explicit-argument range of a callable declaration.
|
|
975
|
+
*
|
|
976
|
+
* `binding` selects the call form: `"bound"` (default) drops the declaration's receiver parameter
|
|
977
|
+
* because the call form supplies it, while `"unbound"` counts it as an explicit argument. Python
|
|
978
|
+
* static methods and module functions declare no receiver and never drop a parameter; JS/TS `this`
|
|
979
|
+
* parameters are type-only and never occupy a slot. Returns null for unknown languages or shapes
|
|
980
|
+
* the grammar cannot prove.
|
|
981
|
+
*/
|
|
982
|
+
export function getCallableArity(args) {
|
|
983
|
+
const profile = getCallableArityProfile(args.languageId);
|
|
984
|
+
if (!profile) {
|
|
985
|
+
return null;
|
|
986
|
+
}
|
|
987
|
+
const enumeration = enumerateParameters(profile, args.declaration, args.source);
|
|
988
|
+
if (enumeration === null) {
|
|
989
|
+
return null;
|
|
990
|
+
}
|
|
991
|
+
const kind = kindFor(profile, args.declaration, enumeration.parameters);
|
|
992
|
+
return arityOfParameters(profile, enumeration.parameters, enumeration.hasRest, args.binding ?? "bound", kind);
|
|
993
|
+
}
|
|
994
|
+
/** Compute the receiver kind and both call-form ranges in one parameter scan. */
|
|
995
|
+
export function getCallableDeclarationFacts(args) {
|
|
996
|
+
const profile = getCallableArityProfile(args.languageId);
|
|
997
|
+
if (!profile)
|
|
998
|
+
return null;
|
|
999
|
+
const enumeration = enumerateParameters(profile, args.declaration, args.source);
|
|
1000
|
+
if (!enumeration)
|
|
1001
|
+
return null;
|
|
1002
|
+
const kind = kindFor(profile, args.declaration, enumeration.parameters);
|
|
1003
|
+
const arity = arityOfParameters(profile, enumeration.parameters, enumeration.hasRest, "bound", kind);
|
|
1004
|
+
if (kind === "function" || kind === "static-method")
|
|
1005
|
+
return { kind, arity };
|
|
1006
|
+
const unboundArity = arityOfParameters(profile, enumeration.parameters, enumeration.hasRest, "unbound", kind);
|
|
1007
|
+
return unboundArity.minArgs !== arity.minArgs || unboundArity.maxArgs !== arity.maxArgs
|
|
1008
|
+
? { kind, arity, unboundArity }
|
|
1009
|
+
: { kind, arity };
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* The kind of callable a declaration is. Python decorators separate instance methods, class
|
|
1013
|
+
* methods, and static methods; other languages only distinguish receiver-bearing methods from
|
|
1014
|
+
* plain functions. Returns null for unknown languages or nodes that declare no callable.
|
|
1015
|
+
*/
|
|
1016
|
+
export function getCallableDeclarationKind(args) {
|
|
1017
|
+
const profile = getCallableArityProfile(args.languageId);
|
|
1018
|
+
if (!profile) {
|
|
1019
|
+
return null;
|
|
1020
|
+
}
|
|
1021
|
+
const scopedRule = profile.receiver.scopedFirstParameter;
|
|
1022
|
+
if (scopedRule) {
|
|
1023
|
+
return scopedKindOf(args.declaration, scopedRule);
|
|
1024
|
+
}
|
|
1025
|
+
const enumeration = enumerateParameters(profile, args.declaration, args.source);
|
|
1026
|
+
if (enumeration === null) {
|
|
1027
|
+
return null;
|
|
1028
|
+
}
|
|
1029
|
+
return kindFor(profile, args.declaration, enumeration.parameters);
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Accepted explicit-argument range from raw parameter-list text: the source-level fallback used
|
|
1033
|
+
* when no tree is available. Splitting and classification share the node-path rules so both paths
|
|
1034
|
+
* answer the same question the same way.
|
|
1035
|
+
*/
|
|
1036
|
+
export function getCallableArityFromParameterText(args) {
|
|
1037
|
+
const profile = getCallableArityProfile(args.languageId);
|
|
1038
|
+
if (!profile) {
|
|
1039
|
+
return null;
|
|
1040
|
+
}
|
|
1041
|
+
const groups = splitTopLevelCommaGroups(args.parameterText, "type-context", profile.signatureCommaScanDetectsRegexLiterals);
|
|
1042
|
+
if (!groups) {
|
|
1043
|
+
return null;
|
|
1044
|
+
}
|
|
1045
|
+
const parameters = groups.map((text) => ({
|
|
1046
|
+
text,
|
|
1047
|
+
nodeType: null,
|
|
1048
|
+
slots: parameterSlotCount(profile, null, text),
|
|
1049
|
+
forcedOptional: false,
|
|
1050
|
+
forcedRest: false,
|
|
1051
|
+
forcedZeroSlot: false,
|
|
1052
|
+
}));
|
|
1053
|
+
return arityOfParameters(profile, parameters, false, args.binding ?? "bound", "function");
|
|
1054
|
+
}
|
|
1055
|
+
function hasUncountableSpreadArgument(profile, arg, nodeType) {
|
|
1056
|
+
if (nodeType !== null && profile.spreadNodeTypes.includes(nodeType)) {
|
|
1057
|
+
return true;
|
|
1058
|
+
}
|
|
1059
|
+
const trimmed = arg.trim();
|
|
1060
|
+
if (trimmed.startsWith("...")) {
|
|
1061
|
+
return true;
|
|
1062
|
+
}
|
|
1063
|
+
return profile.spreadPrefixes.some((prefix) => trimmed.startsWith(prefix));
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Explicit argument count of a call, counting trailing closures as arguments where the language
|
|
1067
|
+
* treats them that way (Swift, Kotlin). Returns null when an argument spread makes the count
|
|
1068
|
+
* unprovable or when the call shape is unknown.
|
|
1069
|
+
*/
|
|
1070
|
+
export function getCallArgumentCount(args) {
|
|
1071
|
+
const profile = getCallableArityProfile(args.languageId);
|
|
1072
|
+
if (!profile) {
|
|
1073
|
+
return null;
|
|
1074
|
+
}
|
|
1075
|
+
const callNode = outermostTrailingClosureCall(args.call, args.source);
|
|
1076
|
+
const argumentNode = findArgumentNode(callNode);
|
|
1077
|
+
const trailingCount = countTrailingClosureArguments(profile, findTrailingScope(callNode), argumentNode ? argumentNode.endIndex : -1);
|
|
1078
|
+
if (argumentNode) {
|
|
1079
|
+
const count = countArgumentElements(profile, argumentNode, args.source);
|
|
1080
|
+
if (count === null) {
|
|
1081
|
+
return null;
|
|
1082
|
+
}
|
|
1083
|
+
return count + trailingCount;
|
|
1084
|
+
}
|
|
1085
|
+
if (profile.callsiteParenthesesFallback) {
|
|
1086
|
+
const openIndex = findOpeningParen(args.source, callNode.startIndex);
|
|
1087
|
+
const balanced = findBalancedParentheses(args.source, openIndex);
|
|
1088
|
+
if (!balanced) {
|
|
1089
|
+
return null;
|
|
1090
|
+
}
|
|
1091
|
+
return getCallArgumentCountFromArgumentText({ languageId: args.languageId, argumentText: balanced.inner });
|
|
1092
|
+
}
|
|
1093
|
+
return trailingCount > 0 ? trailingCount : null;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Explicit argument count from raw argument-list text: the source-level fallback used when no tree
|
|
1097
|
+
* is available. Spread arguments make the count unprovable and return null.
|
|
1098
|
+
*/
|
|
1099
|
+
export function getCallArgumentCountFromArgumentText(args) {
|
|
1100
|
+
const profile = getCallableArityProfile(args.languageId);
|
|
1101
|
+
if (!profile) {
|
|
1102
|
+
return null;
|
|
1103
|
+
}
|
|
1104
|
+
const groups = splitTopLevelCommaGroups(args.argumentText, "type-context");
|
|
1105
|
+
if (!groups) {
|
|
1106
|
+
return null;
|
|
1107
|
+
}
|
|
1108
|
+
for (const group of groups) {
|
|
1109
|
+
if (hasUncountableSpreadArgument(profile, group, null)) {
|
|
1110
|
+
return null;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
return groups.length;
|
|
1114
|
+
}
|
|
1115
|
+
function outermostTrailingClosureCall(call, source) {
|
|
1116
|
+
let callNode = call;
|
|
1117
|
+
let parent = callNode.parent;
|
|
1118
|
+
while (parent && CALL_NODE_TYPES[parent.type]) {
|
|
1119
|
+
const trailingText = source.slice(callNode.endIndex, parent.endIndex).trimStart();
|
|
1120
|
+
if (!trailingText.startsWith("{")) {
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1123
|
+
callNode = parent;
|
|
1124
|
+
parent = callNode.parent;
|
|
1125
|
+
}
|
|
1126
|
+
return callNode;
|
|
1127
|
+
}
|
|
1128
|
+
function findArgumentNode(callNode) {
|
|
1129
|
+
const direct = callNode.childForFieldName("arguments") ?? callNode.childForFieldName("args");
|
|
1130
|
+
if (direct && direct.type !== "call_suffix") {
|
|
1131
|
+
return direct;
|
|
1132
|
+
}
|
|
1133
|
+
for (const child of callNode.namedChildren ?? []) {
|
|
1134
|
+
if (ARGUMENT_LIST_NODE_TYPES[child.type]) {
|
|
1135
|
+
return child;
|
|
1136
|
+
}
|
|
1137
|
+
if (child.type === "call_suffix") {
|
|
1138
|
+
return child.childForFieldName("arguments") ?? findNestedArgumentList(child);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
for (const child of callNode.namedChildren ?? []) {
|
|
1142
|
+
if (CALL_NODE_TYPES[child.type]) {
|
|
1143
|
+
const nested = findArgumentNode(child);
|
|
1144
|
+
if (nested) {
|
|
1145
|
+
return nested;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
return null;
|
|
1150
|
+
}
|
|
1151
|
+
function findNestedArgumentList(node) {
|
|
1152
|
+
for (const child of node.namedChildren ?? []) {
|
|
1153
|
+
if (ARGUMENT_LIST_NODE_TYPES[child.type]) {
|
|
1154
|
+
return child;
|
|
1155
|
+
}
|
|
1156
|
+
const nested = findNestedArgumentList(child);
|
|
1157
|
+
if (nested) {
|
|
1158
|
+
return nested;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
return null;
|
|
1162
|
+
}
|
|
1163
|
+
function findTrailingScope(callNode) {
|
|
1164
|
+
for (const child of callNode.namedChildren ?? []) {
|
|
1165
|
+
if (child.type === "call_suffix") {
|
|
1166
|
+
return child;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
return callNode;
|
|
1170
|
+
}
|
|
1171
|
+
function countArgumentElements(profile, argumentNode, source) {
|
|
1172
|
+
let count = 0;
|
|
1173
|
+
for (const child of argumentNode.namedChildren ?? []) {
|
|
1174
|
+
if (child.type === "comment") {
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
if (child.type === "ERROR" || child.type === "MISSING") {
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
1180
|
+
if (hasUncountableSpreadArgument(profile, sliceOf(source, child), child.type)) {
|
|
1181
|
+
return null;
|
|
1182
|
+
}
|
|
1183
|
+
count += 1;
|
|
1184
|
+
}
|
|
1185
|
+
return count;
|
|
1186
|
+
}
|
|
1187
|
+
function countTrailingClosureArguments(profile, trailingScope, afterIndex) {
|
|
1188
|
+
if (!profile.trailingClosureNodeTypes.length) {
|
|
1189
|
+
return 0;
|
|
1190
|
+
}
|
|
1191
|
+
let count = 0;
|
|
1192
|
+
for (const child of trailingScope.namedChildren ?? []) {
|
|
1193
|
+
if (child.startIndex >= afterIndex && profile.trailingClosureNodeTypes.includes(child.type)) {
|
|
1194
|
+
count += 1;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
return count;
|
|
1198
|
+
}
|
|
1199
|
+
//# sourceMappingURL=callable-arity.js.map
|