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

Method react_component_hoc

codegraph-kernel/src/tsjs/extractors.rs:199–226  ·  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

197 /// inner is the inline render function, or None for `styled.x`/`memo(Ref)`.
198 /// Outer None = not a component wrapper.
199 fn react_component_hoc(&self, value: Node<'t>) -> Option<Option<Node<'t>>> {
200 if self.is_typed_styled_template(value) {
201 return Some(None);
202 }
203 if value.kind() != "call_expression" {
204 return None;
205 }
206 let callee = value.child_by_field_name("function")?;
207 let callee_text = self.text(callee);
208 if util::styled_callee().is_match(callee_text) {
209 return Some(None);
210 }
211 if !is_react_hoc(callee_text) {
212 return None;
213 }
214 let mut inner: Option<Node> = None;
215 if let Some(args) = value.child_by_field_name("arguments") {
216 for i in 0..args.named_child_count() {
217 if let Some(a) = args.named_child(i) {
218 if matches!(a.kind(), "arrow_function" | "function_expression") {
219 inner = Some(a);
220 break;
221 }
222 }
223 }
224 }
225 Some(inner)
226 }
227
228 /// A typed styled tag, `styled.div<Props>` before a template literal, which
229 /// parses as comparisons: `(styled.div < Props) > template`. The leftmost

Callers 1

extract_variableMethod · 0.80

Calls 3

is_react_hocFunction · 0.85
textMethod · 0.65

Tested by

no test coverage detected