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

Method named_primary_ctor

codegraph-kernel/src/dart.rs:1139–1164  ·  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

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