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

Method react_component_hoc

codegraph-kernel/src/tsjs/extractors.rs:293–318  ·  view source on GitHub ↗

Some(inner) when the initializer is a recognized component wrapper — inner is the inline render function, or None for `styled.x`/`memo(Ref)`. Outer None = not a component wrapper.

(&self, value: Node<'t>)

Source from the content-addressed store, hash-verified

291 /// inner is the inline render function, or None for `styled.x`/`memo(Ref)`.
292 /// Outer None = not a component wrapper.
293 fn react_component_hoc(&self, value: Node<'t>) -> Option<Option<Node<'t>>> {
294 if self.is_typed_styled_template(value) {
295 return Some(None);
296 }
297 if value.kind() != "call_expression" {
298 return None;
299 }
300 let callee = value.child_by_field_name("function")?;
301 let callee_text = self.text(callee);
302 if util::styled_callee().is_match(callee_text) {
303 return Some(None);
304 }
305 if !is_react_hoc(callee_text) {
306 return None;
307 }
308 let mut inner: Option<Node> = None;
309 if let Some(args) = value.child_by_field_name("arguments") {
310 for a in args.named_children(&mut args.walk()) {
311 if matches!(a.kind(), "arrow_function" | "function_expression") {
312 inner = Some(a);
313 break;
314 }
315 }
316 }
317 Some(inner)
318 }
319
320 /// A typed styled tag, `styled.div<Props>` before a template literal, which
321 /// parses as comparisons: `(styled.div < Props) > template`. The leftmost

Callers 1

extract_variableMethod · 0.80

Calls 4

is_react_hocFunction · 0.85
textMethod · 0.65
walkMethod · 0.45

Tested by

no test coverage detected