MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / extract_const_or_var

Method extract_const_or_var

atomic-semantic/src/parsers/go.rs:183–199  ·  view source on GitHub ↗

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>,
    )

Source from the content-addressed store, hash-verified

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(

Callers 1

walk_treeMethod · 0.80

Calls 5

walkMethod · 0.80
childrenMethod · 0.80
extract_specMethod · 0.80
kindMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected