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

Method extract_property

codegraph-kernel/src/csharp.rs:814–869  ·  view source on GitHub ↗

extractProperty (1986) — property_declaration only (dispatch-gated to class-like scopes). Type refs come from the `type` field; the caller walks the bodies (property_bodies) with the returned row on the stack.

(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

812 /// class-like scopes). Type refs come from the `type` field; the caller
813 /// walks the bodies (property_bodies) with the returned row on the stack.
814 fn extract_property(&mut self, node: Node<'t>) -> Option<(u32, String)> {
815 let docstring = preceding_docstring(node, self.src);
816 let visibility = Some(self.visibility_of(node));
817 let is_static = Some(self.is_static(node)); // ?? false — always concrete
818
819 let name_node = node
820 .child_by_field_name("name")
821 .or_else(|| node.child_by_field_name("property"))
822 .or_else(|| {
823 (0..node.named_child_count())
824 .filter_map(|i| node.named_child(i))
825 .find(|c| c.kind() == "identifier")
826 });
827 let name_node = name_node?;
828 let name = self.text(name_node).to_string();
829 if name.is_empty() {
830 return None;
831 }
832
833 // Generic scan (isTsJsField=false): FIRST namedChild that isn't a
834 // modifier/name/accessor/initializer. A BARE-identifier declared type
835 // (`public Widget Parent {get;}`) is excluded by the `identifier`
836 // filter → the signature loses its type (QUIRK, preserve); the type
837 // ref below still fires via the `type` FIELD.
838 let type_node = (0..node.named_child_count())
839 .filter_map(|i| node.named_child(i))
840 .find(|c| {
841 !matches!(
842 c.kind(),
843 "modifier" | "modifiers" | "identifier" | "accessor_list" | "accessors"
844 | "equals_value_clause"
845 )
846 });
847 let type_text = type_node.map(|t| {
848 let raw = self.text(t);
849 // TS `.replace(/^:\s*/, '')` — inert for C# type text; mirrored.
850 match raw.strip_prefix(':') {
851 Some(rest) => rest.trim_start_matches(is_js_space).to_string(),
852 None => raw.to_string(),
853 }
854 });
855 let signature = match &type_text {
856 Some(t) => format!("{t} {name}"),
857 None => name.clone(),
858 };
859
860 let row = self.create_node(
861 "property",
862 &name,
863 node,
864 Extra { docstring, signature: Some(signature), visibility, is_static, ..Extra::default() },
865 )?;
866 // decorators: none for C#; then the csharp type-ref path.
867 self.extract_csharp_type_refs(node, row);
868 Some((row, name))
869 }
870
871 /// extractField (2046) — field_declaration; each declarator becomes a

Callers 1

visit_nodeMethod · 0.45

Calls 7

preceding_docstringFunction · 0.85
mapMethod · 0.80
textMethod · 0.65
visibility_ofMethod · 0.45
is_staticMethod · 0.45
create_nodeMethod · 0.45

Tested by

no test coverage detected