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

Function grammar_info

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

Source from the content-addressed store, hash-verified

90
91#[napi]
92pub fn grammar_info(language: String) -> Option<GrammarInfo> {
93 let lang = langs::grammar_for(&language)?;
94 let node_kind_count = lang.node_kind_count();
95 let field_count = lang.field_count();
96 let node_kinds = (0..node_kind_count)
97 .map(|i| lang.node_kind_for_id(i as u16).unwrap_or("").to_string())
98 .collect();
99 // Field ids are 1-based in tree-sitter.
100 let field_names = (1..=field_count)
101 .map(|i| lang.field_name_for_id(i as u16).unwrap_or("").to_string())
102 .collect();
103 Some(GrammarInfo {
104 abi_version: lang.abi_version() as u32,
105 node_kind_count: node_kind_count as u32,
106 field_count: field_count as u32,
107 node_kinds,
108 field_names,
109 })
110}
111
112/// One struct node's extent for the cFnPtr sweep (mirror of the TS caller's
113/// `{ 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