Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
2b6a00d
fix: scope codegraph batch complexity targets to file paths
carlos-alm Jul 5, 2026
b28051a
fix: exclude parameters and interface/type members from dead-role cla…
carlos-alm Jul 5, 2026
17fbcba
fix: credit import-type usages as exports consumers
carlos-alm Jul 5, 2026
26918bb
fix: prevent fn-impact/query crash when -f/--file is passed
carlos-alm Jul 5, 2026
be6432c
fix: correct exported-symbol detection for literal and object-literal…
carlos-alm Jul 5, 2026
4ead840
fix: exclude primitive type keywords from ast --kind string matching
carlos-alm Jul 5, 2026
f6326bf
fix: resolve call edges through renamed import specifiers
carlos-alm Jul 5, 2026
590f560
fix: couple file_hashes updates with edge regeneration in incremental…
carlos-alm Jul 5, 2026
d3ea4a4
fix: compare signature-change diffs using new-file line ranges
carlos-alm Jul 5, 2026
c306812
feat: add environment doctor check for stale native binary and missin…
carlos-alm Jul 5, 2026
8bb5893
fix: eliminate non-deterministic ordering in community detection
carlos-alm Jul 6, 2026
46037b1
fix: sync update-graph.sh hook extension allowlist with EXTENSIONS
carlos-alm Jul 6, 2026
6a84cf9
fix: recompute directory structure metrics for affected directories o…
carlos-alm Jul 6, 2026
8d936d1
refactor: register hardcoded execFileSync/execSync maxBuffer values i…
carlos-alm Jul 6, 2026
11c84be
fix: gate blast-radius check on newly introduced risk, not pre-existi…
carlos-alm Jul 6, 2026
963301a
fix: gate identifier-argument dynamic call edges on callback-acceptin…
carlos-alm Jul 6, 2026
3e8035d
fix: gate Array.from's callback arg by position, not just callee name
carlos-alm Jul 6, 2026
879635e
fix: scope reexportedSymbols to actually-named re-export specifiers
carlos-alm Jul 6, 2026
0fe9fc3
fix: stop CFG block/edge count from overriding AST-derived cyclomatic…
carlos-alm Jul 6, 2026
ccf3c19
fix: backfill edges.technique for incrementally-inserted calls edges
carlos-alm Jul 6, 2026
d5b1162
fix: wrap remote embedding JSON parse failure in EngineError
carlos-alm Jul 6, 2026
8971017
refactor: extract shared platform-default-path helper in config.ts
carlos-alm Jul 6, 2026
056c5e4
refactor: decompose loadConfig and related high-effort functions in c…
carlos-alm Jul 6, 2026
0738171
refactor: decompose findDbPath and openRepo in db/connection.ts (docs…
carlos-alm Jul 6, 2026
6f2423c
refactor: dedupe busy/locked error detection into isBusyOrLockedError
carlos-alm Jul 6, 2026
4c02378
fix: log statSync failures in findDbPath instead of silently swallowi…
carlos-alm Jul 6, 2026
0698e16
test: add direct unit coverage for closeDbPair/closeDbPairDeferred/cl…
carlos-alm Jul 6, 2026
4ac3b99
fix: correct blast-radius/fn-impact computation for line-shifted decl…
carlos-alm Jul 6, 2026
6767f09
feat: wire points-to solver max-iterations cap through DEFAULTS.analy…
carlos-alm Jul 6, 2026
5f6f30a
refactor: route console.log calls in domain/search through logger
carlos-alm Jul 6, 2026
b479318
refactor: reduce cyclomatic complexity of computeDeltaModularityDirected
carlos-alm Jul 6, 2026
c39ac40
refactor: unify impact-level rendering format between audit and fn-im…
carlos-alm Jul 6, 2026
067674f
refactor: dedupe computeSavings via pct helper and persist partial to…
carlos-alm Jul 6, 2026
f6807b4
fix: add main.rs driver to rust dynamic tracer fixture
carlos-alm Jul 6, 2026
1c07a54
fix: scope diff file-header detection to between-hunk positions
carlos-alm Jul 6, 2026
bf82aa2
fix: update titan-grind's dead-symbol script for current roles --json…
carlos-alm Jul 6, 2026
cd02d27
fix: thread configured busyTimeoutMs through remaining read-only quer…
carlos-alm Jul 6, 2026
980b5dc
fix: resolve computed string-literal keys in object-literal extractio…
carlos-alm Jul 6, 2026
4a873a3
fix: add same-class bare-call fallback to incremental rebuild path (d…
carlos-alm Jul 6, 2026
8f3348a
fix: unify Object.defineProperty accessor fallback kind-filtering bet…
carlos-alm Jul 6, 2026
acf804c
refactor: share chunked statement-cache primitive between builder and…
carlos-alm Jul 6, 2026
986c851
refactor: cache prepared statements in applyEdgeTechniquesAfterNative…
carlos-alm Jul 6, 2026
71e9174
fix: replace fixed-depth directory-proximity check with symmetric dis…
carlos-alm Jul 6, 2026
d2935cc
refactor: remove unreachable Partition delta-computation interface me…
carlos-alm Jul 6, 2026
6515186
fix: emit reference edges for function identifiers used as object-lit…
carlos-alm Jul 6, 2026
30c491a
refactor: unify call-ref and tests rendering format between audit and…
carlos-alm Jul 6, 2026
9db911b
fix: classify destructured bindings as constant, not function (docs c…
carlos-alm Jul 6, 2026
70559fc
refactor: adopt timeMedian in remaining benchmark timing loops
carlos-alm Jul 6, 2026
822e0eb
refactor: decompose runPerfBenchmarks in token-benchmark.ts
carlos-alm Jul 6, 2026
fcdfe7d
fix: attribute liveness to Lua functions assigned to global/builtin i…
carlos-alm Jul 6, 2026
ee6362c
refactor: extract shared sedi() helper for tracer scripts
carlos-alm Jul 6, 2026
d4e6212
fix: restore reflection dynamicKind for .call/.apply/.bind (docs chec…
carlos-alm Jul 6, 2026
aec5d2b
fix: restrict entry-role classification to function/method-kind symbo…
carlos-alm Jul 6, 2026
d250f8d
fix: credit destructured dynamic import() bindings as exports consumers
carlos-alm Jul 6, 2026
75978e2
fix: recognize Lua function nodes in complexity metrics computation (…
carlos-alm Jul 6, 2026
af17b6d
fix: scope global call-resolution fallback to same-language candidate…
carlos-alm Jul 6, 2026
dd447bc
fix: credit instanceof ClassName checks as exports consumers
carlos-alm Jul 6, 2026
a79a8a1
fix: update automated-review workflow to use current claude-code-acti…
carlos-alm Jul 6, 2026
d84f6b5
refactor: widen outputResult signature, remove redundant casts at cal…
carlos-alm Jul 6, 2026
e7a2255
fix: port Leiden algorithm to native Rust for cross-engine community-…
carlos-alm Jul 7, 2026
b54972a
feat: detect exported-symbol loss from full file deletion in checkNoS…
carlos-alm Jul 7, 2026
1821a8b
fix(complexity): scope summary stats to file/target/kind filters
carlos-alm Jul 7, 2026
d45aba7
fix(extractors): label property_signature interface/type members as k…
carlos-alm Jul 7, 2026
69d8a6f
fix(roles): exclude genuine class/struct properties from dead-role cl…
carlos-alm Jul 7, 2026
db08219
fix(resolver): scope extends/implements edges to same-file/import/lan…
carlos-alm Jul 7, 2026
79cd761
fix: track inline per-specifier type-only import modifier
carlos-alm Jul 7, 2026
cbfa954
fix(native): widen NativeRepository file filters to accept string[]
carlos-alm Jul 7, 2026
c0e7eae
fix(native): remove unused source param from get_first_call_arg
carlos-alm Jul 7, 2026
2dabe21
fix(extractors): align native/WASM definitions order for object-liter…
carlos-alm Jul 7, 2026
b1eb9af
fix(extractors): capture top-level const definitions regardless of in…
carlos-alm Jul 7, 2026
4a1e279
fix: exclude PHP scalar type-hint/cast keywords from ast --kind string
carlos-alm Jul 7, 2026
40b5e24
fix: track barrel re-export renames (export { X as Y } from ...)
carlos-alm Jul 7, 2026
1506896
fix: record local alias for dynamic import() destructuring renames
carlos-alm Jul 7, 2026
2dfd6bc
fix: resolve renamed-import receiver calls in qualified-method lookup
carlos-alm Jul 7, 2026
ccea0cb
fix(native): propagate edge/node write failures out of run_pipeline
carlos-alm Jul 7, 2026
93ccfa3
fix(exports): discriminate file-level from symbol-level consumer entries
carlos-alm Jul 7, 2026
e105c26
docs: refresh CONTRIBUTING.md for TypeScript architecture and current…
carlos-alm Jul 7, 2026
5d99bf0
fix(exports): credit plain imports of TypeScript interfaces/type aliases
carlos-alm Jul 7, 2026
e0ab9dc
fix(hooks): point update-graph.sh fallback build path at dist/cli.js
carlos-alm Jul 7, 2026
730b49b
fix(hooks): resolve track-edits.sh's PROJECT_DIR from the edited file…
carlos-alm Jul 7, 2026
0d7e8e6
fix: capture removed files' cross-directory neighbors before purge
carlos-alm Jul 7, 2026
c5b9a34
docs: fix stale codegraph check flag names in recommended-practices.md
carlos-alm Jul 7, 2026
2de6550
fix(cycles): classify cycles whose only closing edges are speculative
carlos-alm Jul 7, 2026
e5fe754
fix(resolver): recognize identifier args to user-defined higher-order…
carlos-alm Jul 8, 2026
4eef28e
fix(native): scope barrel-only import skipping to transient barrel re…
carlos-alm Jul 8, 2026
4090355
refactor(ast-analysis): extract shared CFG/complexity result-merging …
carlos-alm Jul 8, 2026
bf8e969
fix(incremental): port CHA/RTA dispatch, points-to, and dynamic-sink …
carlos-alm Jul 8, 2026
51b9e23
fix(config): derive ENV_LLM_KEYS from ENV_LLM_MAP to prevent drift
carlos-alm Jul 8, 2026
a62bab7
fix(resolver): resolveByGlobal picks the single best match, not every…
carlos-alm Jul 8, 2026
8f52d28
fix(embed): resolve default DB path from positional dir, not cwd
carlos-alm Jul 8, 2026
59220a5
refactor(leiden): extract makePartition's inline getters to cut cyclo…
carlos-alm Jul 8, 2026
2e1aa11
docs: regenerate stale audit/diff-impact example output blocks
carlos-alm Jul 8, 2026
3d436ca
fix(rust): resolve self.field, unit-struct, and constructor-typed locals
carlos-alm Jul 8, 2026
668451c
docs: add missing titan-grind mirror to claude-code-skills examples
carlos-alm Jul 8, 2026
4bccd4b
fix(scripts): migrate ts-resolve-loader.js off deprecated module.regi…
carlos-alm Jul 8, 2026
25ba42f
fix(native): recover renamed import names in the FFI hybrid import-ed…
carlos-alm Jul 8, 2026
431c0e5
fix: reconnect reverse-dep edges correctly when a sibling group's siz…
carlos-alm Jul 8, 2026
ab6a685
fix: derive loadConfig() rootDir from --db path in read-only query fu…
carlos-alm Jul 8, 2026
17e265b
fix(native): thread config.db.busyTimeoutMs into NativeDatabase open …
carlos-alm Jul 8, 2026
fdedff8
fix(extractors): unwrap computed string-literal keys in typeMap/proto…
carlos-alm Jul 8, 2026
1e104f1
fix: resolve merge conflicts with main (docs check acknowledged)
carlos-alm Jul 10, 2026
c90afdf
test(native-db): cover the remaining 3 busyTimeoutMs threading call s…
carlos-alm Jul 10, 2026
4d5285e
Merge branch 'fix/issue-1882-thread-config-db-busytimeoutms-into-the-…
carlos-alm Jul 10, 2026
919d77b
Merge branch 'main' into fix/issue-1884-computed-string-literal-keys-…
carlos-alm Jul 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 133 additions & 43 deletions crates/codegraph-core/src/extractors/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,7 @@ fn seed_object_create_entries(var_name: &str, call_node: &Node, source: &[u8], s
let Some(key_n) = child.child_by_field_name("key") else { continue };
let Some(val_n) = child.child_by_field_name("value") else { continue };
if val_n.kind() != "identifier" { continue; }
let key = if key_n.kind() == "string" {
extract_string_fragment(&key_n, source).map(|s| s.to_string())
} else {
Some(node_text(&key_n, source).to_string())
};
let Some(key) = key else { continue };
let Some(key) = resolve_pair_key_name(&key_n, source) else { continue };
symbols.type_map.push(TypeMapEntry {
name: format!("{}.{}", var_name, key),
type_name: node_text(&val_n, source).to_string(),
Expand All @@ -423,12 +418,7 @@ fn seed_descriptor_object(obj_name: &str, obj_node: &Node, source: &[u8], symbol
if child.kind() != "pair" { continue; }
let Some(key_n) = child.child_by_field_name("key") else { continue };
let Some(val_n) = child.child_by_field_name("value") else { continue };
let key = if key_n.kind() == "string" {
extract_string_fragment(&key_n, source).map(|s| s.to_string())
} else {
Some(node_text(&key_n, source).to_string())
};
let Some(key) = key else { continue };
let Some(key) = resolve_pair_key_name(&key_n, source) else { continue };
let Some(target) = find_descriptor_value(&val_n, source) else { continue };
symbols.type_map.push(TypeMapEntry {
name: format!("{}.{}", obj_name, key),
Expand Down Expand Up @@ -659,12 +649,7 @@ fn seed_objlit_type_map_entries(var_name: &str, obj_node: &Node, source: &[u8],
"pair" => {
let Some(key_n) = child.child_by_field_name("key") else { continue };
let Some(val_n) = child.child_by_field_name("value") else { continue };
let key = if key_n.kind() == "string" {
extract_string_fragment(&key_n, source).map(|s| s.to_string())
} else {
Some(node_text(&key_n, source).to_string())
};
let Some(key) = key else { continue };
let Some(key) = resolve_pair_key_name(&key_n, source) else { continue };
let qualified = format!("{}.{}", var_name, key);
match val_n.kind() {
"arrow_function" | "function_expression" | "function" => {
Expand Down Expand Up @@ -962,19 +947,9 @@ fn extract_js_prototype_object_literal(class_name: &str, obj_node: &Node, source
let key_node = child.child_by_field_name("key");
let value_node = child.child_by_field_name("value");
if let (Some(key_node), Some(value_node)) = (key_node, value_node) {
let method_name: &str = if key_node.kind() == "string" {
let s = node_text(&key_node, source);
// Strip exactly one matching pair of surrounding quote characters.
// `trim_matches` would also strip embedded quotes; we only want the
// outermost delimiter pair so `"it's"` stays `it's`.
s.strip_prefix('"').and_then(|s| s.strip_suffix('"'))
.or_else(|| s.strip_prefix('\'').and_then(|s| s.strip_suffix('\'')))
.unwrap_or(s)
} else {
node_text(&key_node, source)
};
let Some(method_name) = resolve_pair_key_name(&key_node, source) else { continue };
if method_name.is_empty() { continue; }
emit_js_prototype_method(class_name, method_name, &value_node, source, symbols);
emit_js_prototype_method(class_name, &method_name, &value_node, source, symbols);
}
}
_ => {}
Expand Down Expand Up @@ -4187,24 +4162,21 @@ fn collect_object_rest_params(node: &Node, source: &[u8], symbols: &mut FileSymb
}
"pair" => {
// object-literal method: `{ bar: function({ ...rest }) {} }`.
// Computed keys are skipped — they can never match a paramBinding callee.
// Computed keys resolve through resolve_pair_key_name, which unwraps resolvable
// string literals (e.g. `['bar']`) and returns None for non-string computed keys
// (e.g. `[Symbol.iterator]`) — those can never match a paramBinding callee.
if let (Some(key_n), Some(value_n)) = (
node.child_by_field_name("key"),
node.child_by_field_name("value"),
) {
let vt = value_n.kind();
if key_n.kind() != "computed_property_name"
&& (vt == "arrow_function" || vt == "function_expression" || vt == "generator_function")
{
let key_text = node_text(&key_n, source);
fn_name = Some(if key_n.kind() == "string" {
key_text[1..key_text.len() - 1].to_string()
} else {
key_text.to_string()
});
params_node = value_n
.child_by_field_name("parameters")
.or_else(|| find_child(&value_n, "formal_parameters"));
if vt == "arrow_function" || vt == "function_expression" || vt == "generator_function" {
if let Some(key_name) = resolve_pair_key_name(&key_n, source) {
fn_name = Some(key_name);
params_node = value_n
.child_by_field_name("parameters")
.or_else(|| find_child(&value_n, "formal_parameters"));
}
}
}
}
Expand Down Expand Up @@ -6217,6 +6189,124 @@ mod tests {
assert!(names.contains(&"obj3.computedVar"), "expected 'obj3.computedVar'; got: {:?}", names);
}

/// Issue #1884: `seed_object_create_entries`'s pair arm must unwrap a computed
/// string-literal key (`Object.create({ ['foo']: fn })`) instead of falling back to the
/// raw bracket/quote source text.
#[test]
fn computed_key_in_object_create_resolves() {
let s = parse_js(
"function fn() {}\n\
const obj = Object.create({ ['foo']: fn });",
);
let entry = s.type_map.iter().find(|e| e.name == "obj.foo");
assert!(entry.is_some(), "type_map should contain 'obj.foo'; got: {:?}", s.type_map);
assert_eq!(entry.unwrap().type_name, "fn");
}

/// Issue #1884: `seed_descriptor_object`'s pair arm (Object.defineProperties) must unwrap
/// a computed string-literal key instead of falling back to the raw bracket/quote text.
#[test]
fn computed_key_in_define_properties_resolves() {
let s = parse_js(
"function f1() {}\n\
const obj = {};\n\
Object.defineProperties(obj, { ['foo']: { value: f1 } });",
);
let entry = s.type_map.iter().find(|e| e.name == "obj.foo");
assert!(entry.is_some(), "type_map should contain 'obj.foo'; got: {:?}", s.type_map);
assert_eq!(entry.unwrap().type_name, "f1");
}

/// Issue #1884: a non-string computed key in Object.defineProperties has no statically
/// resolvable name — must be skipped rather than emitting a garbled entry.
#[test]
fn non_string_computed_key_in_define_properties_skipped() {
let s = parse_js(
"function f1() {}\n\
const obj = {};\n\
Object.defineProperties(obj, { [Symbol.iterator]: { value: f1 } });",
);
assert!(
!s.type_map.iter().any(|e| e.name.contains("Symbol")),
"non-string computed key must not produce a type_map entry; got: {:?}", s.type_map
);
}

/// Issue #1884: `seed_objlit_type_map_entries`'s pair arm (let/var object literals) must
/// unwrap a computed string-literal key instead of falling back to the raw bracket/quote text.
#[test]
fn computed_key_in_let_objlit_pair_seeds_type_map() {
let s = parse_js(
"function handler() {}\n\
var routes = { ['get']: handler };",
);
let entry = s.type_map.iter().find(|e| e.name == "routes.get");
assert!(entry.is_some(), "type_map should contain 'routes.get'; got: {:?}", s.type_map);
assert_eq!(entry.unwrap().type_name, "handler");
}

/// Issue #1884: `extract_js_prototype_object_literal`'s pair arm must unwrap a computed
/// string-literal key instead of falling back to the raw bracket/quote text.
#[test]
fn computed_key_in_prototype_object_literal_pair_resolves() {
let s = parse_js(
"function helper() {}\n\
function C() {}\n\
C.prototype = { ['run']: helper };",
);
let entry = s.type_map.iter().find(|e| e.name == "C.run");
assert!(entry.is_some(), "type_map should contain 'C.run'; got: {:?}", s.type_map);
assert_eq!(entry.unwrap().type_name, "helper");
}

/// Issue #1884: a computed string-literal pair key with a function value in a prototype
/// object literal must emit a method definition under the plain qualified name.
#[test]
fn computed_key_in_prototype_object_literal_pair_fn_value_emits_definition() {
let s = parse_js(
"function C() {}\n\
C.prototype = { ['foo']: function() { return 1; } };",
);
let names: Vec<_> = s.definitions.iter().map(|d| d.name.as_str()).collect();
assert!(names.contains(&"C.foo"), "expected 'C.foo'; got: {:?}", names);
}

/// Issue #1884: `collect_object_rest_params`'s pair arm previously skipped ALL computed
/// keys, including resolvable string literals — it must now unwrap them the same way
/// `resolve_pair_key_name` does elsewhere, instead of blanket-skipping.
#[test]
fn computed_string_literal_key_unwrapped_for_object_rest_param_binding() {
let s = parse_js(
"const api = {\n\
['process']: function({ items, ...rest }) {\n\
rest.flush();\n\
}\n\
};",
);
let b = s.object_rest_param_bindings.iter().find(|b| b.callee == "process");
assert!(b.is_some(), "object_rest_param_bindings missing; got: {:?}", s.object_rest_param_bindings);
let b = b.unwrap();
assert_eq!(b.rest_name, "rest");
assert_eq!(b.arg_index, 0);
}

/// Issue #1884: a non-string computed key must still be skipped for rest-param binding
/// extraction — there's no statically resolvable callee name to bind against.
#[test]
fn non_string_computed_key_still_skipped_for_object_rest_param_binding() {
let s = parse_js(
"const api = {\n\
[Symbol.iterator]: function({ ...rest }) {\n\
rest.flush();\n\
}\n\
};",
);
assert!(
!s.object_rest_param_bindings.iter().any(|b| b.rest_name == "rest"),
"non-string computed key must not produce a binding; got: {:?}", s.object_rest_param_bindings
);
}

/// Issue #1551: `let` and `var` object-literal declarations must seed composite typeMap keys
/// just like `const` declarations. Regression test for the parity gap where native bailed
/// early for non-`const` declarations in the object-literal typeMap walk.
Expand Down
61 changes: 43 additions & 18 deletions src/extractors/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,21 @@ function resolveMethodDefinitionName(nameNode: TreeSitterNode): string {
return resolveComputedKeyName(nameNode);
}

/**
* Resolve an object-literal `pair` node's key field to its plain string form.
*
* Mirrors resolveMethodDefinitionName's computed-key handling so `{ ['foo']: () => {} }` and
* `{ ['foo']() {} }` resolve identically: quoted string keys have their quotes stripped,
* computed string-literal keys (`['foo']`) are unwrapped, and non-string computed keys
* (e.g. `[Symbol.iterator]`) return '' (no resolvable name — caller skips the pair) rather
* than falling back to the raw bracket/quote source text.
*/
function resolvePairKeyName(keyNode: TreeSitterNode): string {
if (keyNode.type === 'string') return keyNode.text.replace(/^['"]|['"]$/g, '');
if (keyNode.type === 'computed_property_name') return resolveComputedKeyName(keyNode);
return keyNode.text;
}

/**
* Push node onto funcStack for a method_definition, qualified with the enclosing class
* name so the PTS key matches callerName from findCaller (which uses
Expand Down Expand Up @@ -2584,8 +2599,7 @@ function handleObjectLiteralTypeMap(
const keyNode = child.childForFieldName('key');
const valNode = child.childForFieldName('value');
if (!keyNode || !valNode) continue;
const keyName =
keyNode.type === 'string' ? keyNode.text.replace(/^['"]|['"]$/g, '') : keyNode.text;
const keyName = resolvePairKeyName(keyNode);
if (!keyName) continue;
const qualifiedKey = `${lhsName}.${keyName}`;
if (
Expand All @@ -2604,7 +2618,9 @@ function handleObjectLiteralTypeMap(
// seed the matching typeMap entry so the two-step accessor dispatch finds it.
const nameNode = child.childForFieldName('name');
if (!nameNode) continue;
setTypeMapEntry(typeMap, `${lhsName}.${nameNode.text}`, `${lhsName}.${nameNode.text}`, 0.85);
const methName = resolveMethodDefinitionName(nameNode);
if (!methName) continue;
setTypeMapEntry(typeMap, `${lhsName}.${methName}`, `${lhsName}.${methName}`, 0.85);
}
}
}
Expand Down Expand Up @@ -2839,7 +2855,8 @@ function handleDefinePropertyTypeMap(
const keyN = pair.childForFieldName('key');
const valN = pair.childForFieldName('value');
if (!keyN || !valN) continue;
const key = keyN.type === 'string' ? keyN.text.replace(/^['"]|['"]$/g, '') : keyN.text;
const key = resolvePairKeyName(keyN);
if (!key) continue;
const target = findDescriptorValue(valN);
if (!target) continue;
setTypeMapEntry(typeMap, `${arg0.text}.${key}`, target, 0.85);
Expand Down Expand Up @@ -2895,7 +2912,8 @@ function seedProtoProperties(
const keyN = child.childForFieldName('key');
const valN = child.childForFieldName('value');
if (!keyN || !valN || valN.type !== 'identifier') continue;
const key = keyN.type === 'string' ? keyN.text.replace(/^['"]|['"]$/g, '') : keyN.text;
const key = resolvePairKeyName(keyN);
if (!key) continue;
setTypeMapEntry(typeMap, `${varName}.${key}`, valN.text, 0.85);
}
}
Expand Down Expand Up @@ -3158,16 +3176,20 @@ function collectObjectRestParams(
}
} else if (t === 'pair') {
// object-literal method: `{ bar: function({ a, ...rest }) {} }`
// Skip computed property keys (e.g. `{ [Symbol.iterator]: function({ ...rest }) {} }`)
// because `callee: '[Symbol.iterator]'` can never match a paramBinding callee.
// Computed keys resolve through resolvePairKeyName, which unwraps resolvable
// string literals (e.g. `['bar']`) and returns '' for non-string computed keys
// (e.g. `[Symbol.iterator]`) — `callee: ''` can never match a paramBinding callee.
const keyN = node.childForFieldName('key');
const valueN = node.childForFieldName('value');
if (keyN && valueN && keyN.type !== 'computed_property_name') {
if (keyN && valueN) {
const vt = valueN.type;
if (vt === 'arrow_function' || vt === 'function_expression' || vt === 'generator_function') {
fnName = keyN.type === 'string' ? keyN.text.slice(1, -1) : keyN.text;
paramsNode =
valueN.childForFieldName('parameters') ?? findChild(valueN, 'formal_parameters');
const keyName = resolvePairKeyName(keyN);
if (keyName) {
fnName = keyName;
paramsNode =
valueN.childForFieldName('parameters') ?? findChild(valueN, 'formal_parameters');
}
}
}
}
Expand Down Expand Up @@ -4685,12 +4707,15 @@ function extractPrototypeObjectLiteral(
// Shorthand method: `Foo.prototype = { bar() {} }`
const nameNode = child.childForFieldName('name');
if (nameNode) {
definitions.push({
name: `${className}.${nameNode.text}`,
kind: 'method',
line: nodeStartLine(child),
endLine: nodeEndLine(child),
});
const methodName = resolveMethodDefinitionName(nameNode);
if (methodName) {
definitions.push({
name: `${className}.${methodName}`,
kind: 'method',
line: nodeStartLine(child),
endLine: nodeEndLine(child),
});
}
}
continue;
}
Expand All @@ -4709,7 +4734,7 @@ function extractPrototypeObjectLiteral(
const valueNode = child.childForFieldName('value');
if (!keyNode || !valueNode) continue;

const methodName = keyNode.type === 'string' ? keyNode.text.replace(/['"]/g, '') : keyNode.text;
const methodName = resolvePairKeyName(keyNode);
if (!methodName) continue;

emitPrototypeMethod(className, methodName, valueNode, definitions, typeMap);
Expand Down
Loading
Loading