MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / normalize

Function normalize

codegraph-kernel/src/tsjs/fnref.rs:118–133  ·  view source on GitHub ↗

normalizeValue for the TS/JS spec: bare identifiers, plus the `this. ` member_expression special form (object EXACTLY `this`).

(node: Node<'t>, src: &str)

Source from the content-addressed store, hash-verified

116/// normalizeValue for the TS/JS spec: bare identifiers, plus the
117/// `this.<member>` member_expression special form (object EXACTLY `this`).
118fn normalize<'t>(node: Node<'t>, src: &str) -> Vec<(String, Node<'t>)> {
119 match node.kind() {
120 "identifier" => vec![(src[node.byte_range()].to_string(), node)],
121 "member_expression" => {
122 let obj = node.child_by_field_name("object");
123 let prop = node.child_by_field_name("property");
124 if let (Some(o), Some(p)) = (obj, prop) {
125 if o.kind() == "this" && p.kind() == "property_identifier" {
126 return vec![(format!("this.{}", &src[p.byte_range()]), p)];
127 }
128 }
129 vec![]
130 }
131 _ => vec![],
132 }
133}

Callers 2

handleFileViewMethod · 0.85
captureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected