Extract constant or variable declarations. Handles both single (`const X = 1`) and grouped (`const ( X = 1; Y = 2 )`) forms.
(
&self,
node: &Node,
source: &str,
file_path: &str,
kind: EntityKind,
entities: &mut Vec<Entity>,
)
| 181 | /// |
| 182 | /// Handles both single (`const X = 1`) and grouped (`const ( X = 1; Y = 2 )`) forms. |
| 183 | fn extract_const_or_var( |
| 184 | &self, |
| 185 | node: &Node, |
| 186 | source: &str, |
| 187 | file_path: &str, |
| 188 | kind: EntityKind, |
| 189 | entities: &mut Vec<Entity>, |
| 190 | ) { |
| 191 | let mut cursor = node.walk(); |
| 192 | for child in node.children(&mut cursor) { |
| 193 | if child.kind() == "const_spec" || child.kind() == "var_spec" { |
| 194 | if let Some(entity) = self.extract_spec(&child, source, file_path, kind) { |
| 195 | entities.push(entity); |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /// Extract a single const_spec or var_spec. |
| 202 | fn extract_spec( |