Skip to main content

category_for_node_kind

Function category_for_node_kind 

Source
pub fn category_for_node_kind(
    node_kind: &str,
    _language: &str,
) -> Option<&'static str>
Expand description

Maps a tree-sitter node_kind to the built-in category it belongs to.

Returns None if the node kind does not belong to any category. The _language parameter is reserved for future per-language overrides.

Used internally by classify_hint for non-call/non-macro node kinds; the native pipeline no longer calls this function directly (as of M33). Foreign extractors with full PatternHintInput access should call classify_hint instead. This function is preserved for callers that have a node kind but no source text — and for backward compatibility with embedders that integrated against the M29 API.

§Examples

use sdivi_patterns::queries::category_for_node_kind;

assert_eq!(category_for_node_kind("try_expression", "rust"), Some("error_handling"));
assert_eq!(category_for_node_kind("await_expression", "rust"), Some("async_patterns"));
assert_eq!(category_for_node_kind("unknown_node", "rust"), None);

§See also

classify_hint — callee-text-aware classifier that returns ["logging"] for matching callees and disambiguates Rust macro_invocation into logging vs resource_management. This is what the native pipeline calls since M33.