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

Method named_primary_ctor

codegraph-kernel/src/dart.rs:1132–1157  ·  view source on GitHub ↗

extractDartNamedPrimaryCtor (tree-sitter.ts) — a named Dart 3.13 primary constructor, `class Point.origin(final int x)`, is the type's named constructor: a method named `origin` returning the type (on top of the stack), which a call `Point.origin(…)` links (#3270).

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

Source from the content-addressed store, hash-verified

1130 /// named constructor: a method named `origin` returning the type (on top
1131 /// of the stack), which a call `Point.origin(…)` links (#3270).
1132 fn named_primary_ctor(&mut self, node: Node<'t>) {
1133 let Some(ctor) = node.child_by_field_name("primary_constructor") else { return };
1134 let Some(name) = ctor.child_by_field_name("name").filter(|n| n.kind() == "identifier") else {
1135 return;
1136 };
1137 let type_name = self.stack.last().map(|s| s.name.clone());
1138 let signature = ctor
1139 .child_by_field_name("parameters")
1140 .map(|p| self.text(p).trim().to_string())
1141 .filter(|s| !s.is_empty());
1142 let name = self.text(name).to_string();
1143 self.create_node(
1144 "method",
1145 &name,
1146 ctor,
1147 Extra {
1148 docstring: None,
1149 signature,
1150 visibility: 1,
1151 is_async: Some(false),
1152 is_static: Some(false),
1153 return_type: type_name,
1154 end_line_override: None,
1155 },
1156 );
1157 }
1158
1159 /// extractEnumMembers (:1958) — one enum_member per constant, positioned
1160 /// at the enum_constant node; ctor arguments never walked.

Callers 2

extract_classMethod · 0.80
extract_enumMethod · 0.80

Calls 3

mapMethod · 0.80
textMethod · 0.65
create_nodeMethod · 0.45

Tested by

no test coverage detected