srcmetrics 0.1.0

Language-independent source code metrics (size, complexity, nesting, Halstead, duplication, dependencies, documentation) for C, C++, Go, Java, JavaScript, Python, Rust and TypeScript
Documentation
//! C++ mapping (tree-sitter-cpp). The grammar extends tree-sitter-c's node types.

use super::Mapping;
use crate::ir::NodeKind::*;

pub static MAPPING: Mapping = Mapping {
    language: "cpp",
    extensions: &["cpp", "cc", "cxx", "hpp", "hh", "hxx"],
    grammar: || tree_sitter_cpp::LANGUAGE.into(),
    grammar_crate: ("tree-sitter-cpp", "0.23.4"),
    kinds: &[
        ("compound_statement", Block),
        ("expression_statement", Statement),
        ("declaration", Declaration),
        ("if_statement", Branch),
        ("else_clause", Else),
        ("for_statement", Loop),
        ("for_range_loop", Loop),
        ("while_statement", Loop),
        ("do_statement", Loop),
        ("case_statement", Case),
        ("catch_clause", Catch),
        ("return_statement", Return),
        ("co_return_statement", Return),
        ("break_statement", Jump),
        ("continue_statement", Jump),
        ("goto_statement", Jump),
        ("throw_statement", Jump),
        ("call_expression", Call),
        ("new_expression", Call),
        ("assignment_expression", Assignment),
        ("binary_expression", Binary),
        ("unary_expression", Unary),
        ("update_expression", Unary),
        ("pointer_expression", Unary),
        ("conditional_expression", Conditional),
        ("subscript_expression", Expression),
        ("field_expression", Expression),
        ("cast_expression", Expression),
        ("parenthesized_expression", Expression),
        ("identifier", Identifier),
        ("number_literal", Literal),
        ("string_literal", Literal),
        ("raw_string_literal", Literal),
        ("char_literal", Literal),
        ("concatenated_string", Literal),
        ("user_defined_literal", Literal),
        ("system_lib_string", Literal),
        ("true", Literal),
        ("false", Literal),
        ("null", Literal),
        ("nullptr", Literal),
        ("preproc_include", Import),
        ("function_definition", Function),
        ("lambda_expression", Function),
    ],
    callee_fields: &["function", "type"],
    logical_operators: &["&&", "||", "and", "or"],
    default_case_keyword: Some("default"),
    else_field: None,
    comments: &["comment"],
    literals: &[
        "number_literal",
        "string_literal",
        "raw_string_literal",
        "char_literal",
        "concatenated_string",
        "user_defined_literal",
        "system_lib_string",
        "true",
        "false",
        "null",
        "nullptr",
    ],
    interpolations: &[],
    identifiers: &[
        "identifier",
        "field_identifier",
        "type_identifier",
        "namespace_identifier",
        "statement_identifier",
        "destructor_name",
        "operator_name",
    ],
    name_fields: &["declarator", "name"],
    decorators: &[],
    docstring: None,
    parameter_fields: &["parameters"],
    ignored_parameters: &["void"],
};