Skip to content

Commit aaba0ca

Browse files
committed
fix(native): add string_fragment arm to handle_method_def computed key extraction
1 parent 45630ad commit aaba0ca

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

crates/codegraph-core/src/extractors/javascript.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -964,12 +964,17 @@ fn handle_method_def(node: &Node, source: &[u8], symbols: &mut FileSymbols) {
964964
let inner = name_node.child(1);
965965
match inner {
966966
Some(inner) if inner.kind() == "string" => {
967+
// Use the string_fragment child to get the content without quotes.
968+
let s = extract_string_fragment(&inner, source).unwrap_or("");
969+
if s.is_empty() { return; }
970+
method_name_owned = s.to_string();
971+
&method_name_owned
972+
}
973+
Some(inner) if inner.kind() == "string_fragment" => {
974+
// string_fragment is already quote-free (direct child of computed_property_name).
967975
let s = node_text(&inner, source);
968-
let stripped = s.strip_prefix('"').and_then(|s| s.strip_suffix('"'))
969-
.or_else(|| s.strip_prefix('\'').and_then(|s| s.strip_suffix('\'')))
970-
.unwrap_or(s);
971-
if stripped.is_empty() { return; }
972-
method_name_owned = stripped.to_string();
976+
if s.is_empty() { return; }
977+
method_name_owned = s.to_string();
973978
&method_name_owned
974979
}
975980
_ => return, // non-string computed key — skip

0 commit comments

Comments
 (0)