Skip to main content

get_ops

Function get_ops 

Source
pub fn get_ops(
    lang: &LANG,
    source: Vec<u8>,
    path: &Path,
    pr: Option<Arc<PreprocResults>>,
) -> Result<Ops, MetricsError>
Expand description

Returns all operators and operands of each space in a code.

§Examples

use std::path::PathBuf;

use big_code_analysis::{get_ops, LANG};

let source_code = "int a = 42;";
let language = LANG::Cpp;

// The path to a dummy file used to contain the source code
let path = PathBuf::from("foo.c");
let source_as_vec = source_code.as_bytes().to_vec();

get_ops(&language, source_as_vec, &path, None).unwrap();

§Errors

Returns MetricsError::LanguageDisabled when lang’s per-language Cargo feature is not enabled in this build. The return type also carries MetricsError::EmptyRoot for forward compatibility, but the walker does not produce it today — see the variant doc.