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

Function grammar_info

codegraph-kernel/src/lib.rs:107–125  ·  view source on GitHub ↗
(language: String)

Source from the content-addressed store, hash-verified

105
106#[napi]
107pub fn grammar_info(language: String) -> Option<GrammarInfo> {
108 let lang = langs::grammar_for(&language)?;
109 let node_kind_count = lang.node_kind_count();
110 let field_count = lang.field_count();
111 let node_kinds = (0..node_kind_count)
112 .map(|i| lang.node_kind_for_id(i as u16).unwrap_or("").to_string())
113 .collect();
114 // Field ids are 1-based in tree-sitter.
115 let field_names = (1..=field_count)
116 .map(|i| lang.field_name_for_id(i as u16).unwrap_or("").to_string())
117 .collect();
118 Some(GrammarInfo {
119 abi_version: lang.abi_version() as u32,
120 node_kind_count: node_kind_count as u32,
121 field_count: field_count as u32,
122 node_kinds,
123 field_names,
124 })
125}
126
127/// One struct node's extent for the cFnPtr sweep (mirror of the TS caller's
128/// `{ id, startLine, endLine }`, with `endLine ?? startLine` applied TS-side).

Callers

nothing calls this directly

Calls 2

grammar_forFunction · 0.85
collectMethod · 0.45

Tested by

no test coverage detected